Skip to content

Import Automated Test Results from Pipelines

Disclaimer

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

Step-by-step guide

For a complete walkthrough of setting up CI/CD integration with SquashTM, see our CI/CD How-to Guide.

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

NameTypeRequiredDescription
iteration_idintegerβœ… YesID 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

FieldTypeRequiredDescription
β”Œβ”€ automated_test_suiteobjectNoInfo about the test suite execution.
β”‚    β”œβ”€ statusstringNoTest suite status: BLOCKED, CANCELLED, SUCCESS, RUNNING, SKIPPED or FAILURE. If not provided, it will be auto-calculated.
β”‚    β””─ attachmentsarray of objectsNoFiles attached to the suite.
β”‚          β”œβ”€ namestring🟑 YesFile name with its extension, among txt, html, xml or doc (e.g., report.html).
β”‚          β””─ contentstring🟑 YesBase64-encoded content, with a maximum size defined by the SquashTM instance.
└─ testsarray of objectsπŸ”΄ YesIndividual test results.
      β”œβ”€ referencestringπŸ”΄ YesUnique test identifier (used to map with SquashTM). Example: testSuite.testClass.testRef1
      β”œβ”€ dataset_namestringNoDataset name used in SquashTM.
      β”œβ”€ statusstringπŸ”΄ YesTest status: BLOCKED, CANCELLED, SUCCESS, RUNNING, SKIPPED, FAILURE, or READY.
      β”œβ”€ durationintegerNoTest duration in milliseconds.
      β”œβ”€ failure_detailsarray of stringsNoList of failure messages.
      β”œβ”€ attachmentsarray of objectsNoFiles related to the test.
      β”‚    β”œβ”€ namestring🟑 YesFile name with its extension, among those accepted by the SquashTM instance (e.g., screenshot.png, if png has been added at the system level).
      β”‚    β””─ contentstring🟑 YesBase64-encoded content, with a maximum size defined by the SquashTM instance.
      β”œβ”€ test_stepsarray of objectsNoDetails of individual test steps. The number of these steps must be equal to the number of test steps in the corresponding test case.
      β”‚    β”œβ”€ statusstring🟑 YesTest step status: BLOCKED, CANCELLED, SUCCESS, RUNNING, SKIPPED, FAILURE, or READY.
      β”‚    β””─ attachmentsarray of objectsNoFiles related to the test step.
      β”‚          β”œβ”€ namestring🟑 YesFile name with its extension, among those accepted by the SquashTM instance (e.g., screenshot.png, if png has been added at the system level).
      β”‚          β””─ contentstring🟑 YesBase64-encoded content, with a maximum size defined by the SquashTM instance.
      β””─ custom_fieldsarray of objectsNoCustom fields related to the test.
            β”œβ”€ codestring🟑 YesCode of the custom field as defined in SquashTM.
            β””─ valuestring / integer / boolean / array of strings🟑 YesValue 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

CodeMeaningNotes
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 requestInvalid input.
401πŸ”’ UnauthorizedAuthentication required.
403🚫 ForbiddenAccess denied.
404❓ Not foundIteration not found.
412πŸ›‘ Precondition failedRequest 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 errorUnexpected server error.