Skip to content

Import Automated Test Results from Pipelines

Disclaimer

On SquashTM Cloud instances, this feature is available with a SquashTM Ultimate license.

SquashTM allows you to import the results of automated tests executed in a CI/CD pipeline.

This is done via an API call (see details), which will create a new automated test suite linked to the targeted iteration.

Prerequisites

In order to import test results, an iteration must already exist in SquashTM and its execution plan must be populated with the tests for which results will be imported.

Each of these tests must have a unique (in the iteration's execution plan) automated test reference.

All of these steps can be done via the API if needed:

  • Create test cases: POST request to /test-cases with the automated_test_reference field filled;
  • Create a campaign: POST request to /campaigns;
  • Create an iteration: POST request to /campaigns/{campaign_id}/iterations;
  • Add tests to an iteration: POST request to /iterations/{iteration_id}/test-plan.

For more details on these requests, refer to the API documentation available in SquashTM.

Accessing API doc

Mapping Information

Results will be reintegrated into SquashTM by matching the automated test reference provided in the API request with that of the test in the execution plan of the selected iteration.
If some test cases use datasets, mapping will rely on both the automated test reference and the dataset name associated with the ITPI.

automated test reference

dataset name

The following information can be reported:

  • the test status;
  • the execution duration of the test;
  • the messages of failed assertions;
  • the attachments related to test executions;
  • the custom fields related to test executions.

It is also possible to add attachments at the test suite level.
The test suite status will be automatically calculated based on the individual test results, but can also be overridden if needed.

API Endpoint Documentation

POST /import/results/{iteration_id}

πŸ”Έ Path Parameter

Name Type Required Description
iteration_id integer βœ… Yes ID of the iteration. Must be greater than or equal to 1.

πŸ”Έ Request Body

Note: There are two types of required fields:
- πŸ”΄ : Fields that block the import if they are missing.
- 🟑 : Fields that will result in their current object being rejected if they are invalid or missing, but not blocking the rest of the import.

Content-Type: application/json
Authentication: Bearer token

Field Type Required Description
β”Œβ”€ automated_test_suite object No Info about the test suite execution.
β”‚    β”œβ”€ status string No Test suite status: BLOCKED, CANCELLED, SUCCESS, RUNNING, SKIPPED or FAILURE. If not provided, it will be auto-calculated.
β”‚    β””─ attachments array of objects No Files attached to the suite.
β”‚          β”œβ”€ name string 🟑 Yes File name with its extension, among txt, html, xml or doc (e.g., report.html).
β”‚          β””─ content string 🟑 Yes Base64-encoded content, with a maximum size defined by the SquashTM instance.
└─ tests array of objects πŸ”΄ Yes Individual test results.
      β”œβ”€ reference string πŸ”΄ Yes Unique test identifier (used to map with SquashTM). Example: testSuite.testClass.testRef1
      β”œβ”€ dataset_name string No Dataset name used in SquashTM.
      β”œβ”€ status string πŸ”΄ Yes Test status: BLOCKED, CANCELLED, SUCCESS, RUNNING, SKIPPED, FAILURE, or READY.
      β”œβ”€ duration integer No Test duration in milliseconds.
      β”œβ”€ failure_details array of strings No List of failure messages.
      β”œβ”€ attachments array of objects No Files related to the test.
      β”‚    β”œβ”€ name string 🟑 Yes File name with its extension, among those accepted by the SquashTM instance (e.g., screenshot.png, if png has been added at the system level).
      β”‚    β””─ content string 🟑 Yes Base64-encoded content, with a maximum size defined by the SquashTM instance.
      β”œβ”€ test_steps array of objects No Details of individual test steps. The number of these steps must be equal to the number of test steps in the corresponding test case.
      β”‚    β”œβ”€ status string 🟑 Yes Test step status: BLOCKED, CANCELLED, SUCCESS, RUNNING, SKIPPED, FAILURE, or READY.
      β”‚    β””─ attachments array of objects No Files related to the test step.
      β”‚          β”œβ”€ name string 🟑 Yes File name with its extension, among those accepted by the SquashTM instance (e.g., screenshot.png, if png has been added at the system level).
      β”‚          β””─ content string 🟑 Yes Base64-encoded content, with a maximum size defined by the SquashTM instance.
      β””─ custom_fields array of objects No Custom fields related to the test.
            β”œβ”€ code string 🟑 Yes Code of the custom field as defined in SquashTM.
            β””─ value string / integer / boolean / array of strings 🟑 Yes Value of the custom field. The type depends on the configuration of the field in SquashTM.

Example:

{
  "automated_test_suite": {
    "attachments": [
      {
        "name": "report.html",
        "content": "Base64-encoded content here..."
      }
    ]
  },
  "tests": [
    {
      "reference": "testSuite.testClass.testRef1",
      "dataset_name": "admin_dataset",
      "status": "FAILURE",
      "duration": 35000,
      "failure_details": ["1 is not equal to 2"],
      "attachments": [
        {
          "name": "screenshot.png",
          "content": "Base64-encoded content here..."
        }
      ],
      "test_steps": [
        {
            "status": "SUCCESS"
        },
        {
          "status": "FAILURE",
            "attachments": [
              {
                "name": "step_screenshot.png",
                "content": "Base64-encoded content here..."
              }
            ]
        }
      ],
      "custom_fields" : [ {
        "code" : "NUMERIC",
        "value" : 200
      }, {
        "code" : "TEXT",
        "value" : "description"
      }, {
        "code" : "CHECKBOX",
        "value" : "true"
      }, {
        "code" : "TAGS_RELATED",
        "value" : ["tag1", "tag2"]
      } ]
    }
  ]
}

πŸ”Έ Responses

Code Meaning Notes
204 βœ… All results successfully imported into SquashTM.
207 ⚠️ Partial success – some results could not be imported. Response body includes error details, for example:
{
"iteration_id": 1234,
"tests": [
{
"test_case_id": null,
"reference": "testSuite.testClass.testRef1",
"error": "No test found with this reference."
}
]
}
400 πŸ›‘ Bad request Invalid input.
401 πŸ”’ Unauthorized Authentication required.
403 🚫 Forbidden Access denied.
404 ❓ Not found Iteration not found.
412 πŸ›‘ Precondition failed Request body is missing one or more required fields and the import has been aborted. Response body includes error details, for example:
{
"fieldValidationErrors": [
{
"objectName": "post-execution-result-import",
"fieldName": "tests[0].reference",
"fieldValue": null,
"errorMessage": "The reference attribute is required"
}
]
}
500 ❌ Internal error Unexpected server error.