Rerun Test Cases from Run Results using API


In Testsigma, you can re-run the test cases from a test run result using API. This article discusses how to rerun failed test cases, all test cases, or custom test cases from a particular test run result using REST API.


Test Case Execution details using REST API

This endpoint allows users to get details of all Test case executions using REST API.

Request Type GET
Endpoint https://app.testsigma.com/api/v1/executionresults/986/testcase_results
Authorization Bearer <API_Token>
Same as the Testsigma API key mentioned above.
Request Body
{ 
"executionId": 268,
"executionResultId": 986,
"result": "FAILURE",
"status": "STATUS_COMPLETED",
"testCases": [
{
"testCaseId": 413,
"testCaseName": "03 data driven small",
"testCaseResultId": 7975,
"result": "FAILURE",
"isDataDrivenCase": true,
"iterationResults": [
{
"iterationResultId": 7963,
"setName": "examples",
"result": "SUCCESS"
},
{
"iterationResultId": 7976,
"setName": "travels",
"result": "FAILURE"
},
{
"iterationResultId": 7965,
"setName": "examples 1",
"result": "FAILURE"
}
],
"testSuiteId": 197,
"testSuiteName": "02 DD Small",
"testSuiteResultId": 2295,
"machineId": 414,
"machineTitle": "machine 2",
"machineResultId": 2370
}
]
}

Request fields

  • executionId: Execution ID of Test Plan
  • executionResultId: Result ID of Test Plan Execution
  • testCaseId: ID of Test Case
  • testCaseResultId: ID of Test Case result
  • iterationResultId: ID of iteration result
  • testSuiteId: ID of Test Suite
  • testSuiteResultId: ID of Test Suite result

Trigger Rerun using REST API

This endpoint allows users to trigger the rerun of selected test cases using REST API.

Request Type POST
Endpoint https://app.testsigma.com/api/v1/execution_results
Authorization Bearer <API_Token>
Same as the Testsigma API key mentioned above.
Request Body
{ 
"executionId": 336,
"executionResultId": 467,
"isReRun": true,
"reRunType": "USER_PICKED",
"testCaseResultRequests": [
{
"id": 2880
},
{
"id": 2874
}
]
}
Response Body
{ 
"id": 487,
"execution": null,
"executionId": 336,
"startTime": 1679291448332,
"endTime": null,
"duration": null,
"result": "QUEUED",
"status": "STATUS_CREATED",
"message": "Test Plan execution is initiated and waiting to be queued",
"executedBy": 10,
"buildNo": null,
"environmentId": null,
"totalCount": 0,
"failedCount": 0,
"passedCount": 0,
"stoppedCount": 0,
"notExecutedCount": 0,
"queuedCount": 0,
"runningCount": 0,
"visualTestResult": null,
"environment": null,
"childResult": null,
"reRunParentId": 469,
"triggeredType": "API",
"totalRunningCount": 0,
"executionDetails": {
"page_timeout": 30,
"element_timeout": 30,
"recovery_action": "Run_Next_Testcase",
"on_aborted_action": "Reuse_Session",
"screenshot_option": "ALL_TYPES",
"group_prerequisite_fail": "Abort",
"test_case_prerequisite_fail": "Abort",
"test_step_prerequisite_fail": "Run_Next_Testcase",
"global_param_name": null
},
"totalQueuedCount": 0,
"mobileInspectionId": null,
"environmentResultsDTO": null,
"executionResultConfig": null,
"isReRunEnabled": false,
"consolidatedResult": "QUEUED",
"consolidatedStatus": "STATUS_CREATED",
"resultType": "ORIGINAL",
"consolidatedDuration": null,
"runTestCasesInParallel": false,
"runTestSuitesInParallel": false,
"scheduledId": null,
"testPlanHookResults": null
}
NOTE:

If your test case is data-driven, and you need to add iterations, you need to send a different payload. Refer to the sample payload below:

{
"executionId": 325,
"executionResultId": 473,
"isReRun": true,
"reRunType": "USER_PICKED",
"testCaseResultRequests": [
{
"id": 2915,
"iterationReRunType":"USER_PICKED",
"iterationResultIds": [
2916, 2917
]
}
]
}

Request fields

  • executionId: Test Plan Execution ID
  • executionResultId: Test Plan Execution result ID
  • reRunType: Test cases you want to rerun - "ALL_TESTS / ONLY_FAILED_TESTS / ALL_ITERATIONS / ONLY_FAILED_ITERATIONS/ USER_PICKED"
  • iterationReRunType: Iterations you want to rerun - “ALL/FAILED/PASSED/USER_PICKED"

Response fields

  • Id: ID of the Test Plan Result
  • Execution: The Test Plan details are located within the nested Execution JSON Object including the Test Plan ID as "id," Application Version ID as - "applicationVersionId," Test Plan name as "name," Test Plan Description as "description" and so on.
  • result: Result Status of the Test Plan - QUEUED, PASSED, FAILED, ABORTED, or STOPPED
  • status: Current Status of the Test Plan creation - STATUS_CREATED
  • executedBy: ID of the executor
  • buildNo: Build Number specified in the Test Plan Trigger call
  • isVisuallyPassed: Whether visual testing passed or not. True or False.
  • environment: Environment parameter selected for the Test Plan
  • triggeredType: Triggered type for the Test Plan whether by API or via Testsigma App
  • totalRunningCount: Total number of running tests
  • page_timeout: Global Page load timeout in seconds
  • element_timeout: Global Element load timeout in seconds
  • recovery_action: Action to be performed on test failure - "Run_Next_Testcase"
  • onaborted\action: Action to be performed on test abort - "Reuse_Session"
  • screenshot_option: When to take screenshots - "FAILED_STEPS", “ALL_STEPS”, “NONE”
  • group_prerequisite_fail: Action to perform on Test Suite prerequisite failure
  • test_case_prerequisite_fail: Action to perform on Test Case prerequisite failure
  • test_step_prerequisite_fail: Action to perform on Test Step prerequisite failure
  • totalQueuedCount: Total number of queued tests

Stop Rerun using REST API

This endpoint allows users to stop the rerun of already executed test cases using REST API.

Request Type PUT
Endpoint https://app.testsigma.com/api/v1/execution_results
Authorization Bearer <API_Token>
Same as the Testsigma API key mentioned above.
Request Body
{ 
"canStopAll": true,
"result": "STOPPED"
}
Response Body
{ 
"id": 1165,
"execution": {
"id": 339,
"applicationVersionId": 47,
"name": "12 small plan pass",
"description": null,
"mailList": "manoharkrishna@testsigma.com",
"elementTimeOut": 30,
"pageTimeOut": 30,
"environmentId": null,
"screenshot": "ALL_TYPES",
"recoveryAction": "Run_Next_Testcase",
"onAbortedAction": "Reuse_Session",
"onSuitePreRequisiteFail": "Abort",
onStepPreRequisiteFail": "Run_Next_Testcase",
reRunType": "NONE",
"isManual": false,
"applicationVersion": null,
"lastRun": null,
"slack": null,
"createdDate": 1677482960000,
"updatedDate": 1679304114000,
"createdById": 9,
"updatedById": 12,
"matchBrowserVersion": false,
"notificationStatusList": [
"1",
"0",
"9",
"5",
"3",
"6"
],
"msTeamsConnectorNotificationEnabled": false,
"retrySessionCreation": false,
"retrySessionCreationTimeout": null,
"lastRunId": 1165,
"googleChatConnectorNotificationEnabled": false,
"slackConnectorNotificationEnabled": false,
"entityType": "EXECUTION",
"environments": [],
"hookData": null,
"postHookId": null,
"postPlanHook": null,
"visualTestResultTimeOut": 2,
"onTestCasePreRequisiteFail": "Abort",
"executionType": "CUSTOM"
},
"executionId": 339,
"startTime": 1679304114000,
"endTime": 1679304125763,
"duration": 11763,
"result": "STOPPED",
"status": "STATUS_COMPLETED",
"message": "User stopped the Test Plan",
"executedBy": 12,
"buildNo": null,
"environmentId": null,
"totalCount": 1,
"failedCount": 0,
"passedCount": 0,
"stoppedCount": 0,
"notExecutedCount": 0,
"queuedCount": 0,
"runningCount": 1,
"visualTestResult": null,
"environment": null,
"childResult": null,
"reRunParentId": null,
"triggeredType": "MANUAL",
"totalRunningCount": 0,
"executionDetails": {
"page_timeout": 30,
"element_timeout": 30,
"recovery_action": "Run_Next_Testcase",
"on_aborted_action": "Reuse_Session",
"screenshot_option": "ALL_TYPES",
"group_prerequisite_fail": "Abort",
"test_case_prerequisite_fail": "Abort",
"test_step_prerequisite_fail": "Run_Next_Testcase",
"global_param_name": null
},
"totalQueuedCount": 0,
"mobileInspectionId": null,
"environmentResultsDTO": null,
"executionResultConfig": null,
"isReRunEnabled": false,
"consolidatedResult": "STOPPED",
"consolidatedStatus": "STATUS_COMPLETED",
"resultType": "ORIGINAL",
"consolidatedDuration": 11763,
"runTestCasesInParallel": false,
"runTestSuitesInParallel": false,
"scheduledId": null,
"testPlanHookResults": null
}
NOTE:

If you want to stop only one execution run instead, you need to pass "canStopAll": false. By default, it is true.

Request fields

  • canStopAll: "true” if you want to stop all executions. “false” if you want to stop only some executions.
  • result: Result of Execution.

Response fields

  • Id: ID of the Test Plan Result
  • Execution: The Test Plan details are located within the nested Execution JSON Object including the Test Plan ID as "id", Application Version ID as "applicationVersionId", Test Plan name as "name", Test Plan Description as "description" and so on.
  • result: Result Status of the Test Plan - QUEUED, PASSED, FAILED, ABORTED, or STOPPED
  • status: Current Status of the Test Plan creation - STATUS_CREATED
  • executedBy: ID of the executor
  • buildNo: Build Number specified in the Test Plan Trigger call
  • environment: Environment parameter selected for the Test Plan
  • triggeredType: Triggered type for the Test Plan whether by API or via Testsigma App
  • totalRunningCount: Total number of running tests
  • page_timeout: Global Page load timeout in seconds
  • element_timeout: Global Element load timeout in seconds
  • recovery_action: Action to be performed on test failure - "Run_Next_Testcase"
  • on_aborted_action: Action to be performed on test abort - "Reuse_Session"
  • screenshot_option: When to take screenshots - "FAILED_STEPS", "ALL_STEPS", "NONE"
  • group_prerequisite_fail: Action to perform on Test Suite prerequisite failure
  • test_case_prerequisite_fail: Action to perform on Test Case prerequisite failure
  • test_step_prerequisite_fail: Action to perform on Test Step prerequisite failure
  • totalQueuedCount: Total number of queued tests