We can integrate Testsigma with your CI/CD tool to automate a Test Execution when a successful build is triggered.


This is done by making a POST request to Testsigma Test Plan Trigger API and then using the Test Plan Status Check API to regularly check for the execution status until its Complete.


Testsigma Test Plan Trigger API

Go to the specific Test Plan details page in Testsigma tool for the Test Plan that you want to include in your CI Pipeline. The CURL request format for starting a Test Execution can be found on the Execution details page under the CI Integration Details as shown below:

curl -X POST -H "Content-type: application/json" -H "Accept:application/json" -H "Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" https://app.testsigma.com/api/v1/execution_results -d "{\"executionId\": \"2090\"}"

The same can be done using any other REST API Client with the following details:


Request Type: POST
Request URL: https://app.testsigma.com/api/v1/execution_results

Authorization: Bearer API_KEY

Request Header: 

Content-type: application/json
Accept:application/json

Request Body: 

{
    "executionId":"TEST_PLAN_ID",
    "buildNo":"BUILD_NO"
}


 - The TEST_PLAN_ID is used to identify the Test Plan which is to be triggered. This can be obtained from the corresponding Test Plan details page.

- The API_KEY is used to authenticate your user in Testsigma API. This can be obtained from the Configurations > API_Keys by creating a new API Key.

- The BUILD_NO is the Build number/Version for your corresponding Application Build against which you are running the Tests. This can be obtained from the Dev team or Build Stage in the CI/CD Pipeline.


Testsigma Test Plan Status Check API


Same as the above one, this API can be used to check the status of the Test Plan once the Test Plan execution is triggered successfully.


There are 2 differences here compared to the previous API.

1. This is a GET request compared to the previous POST request.

2. We need one more detail i.e the RUN_ID for the triggered Test Plan. This is obtained as value of the key 'id' in the JSON response for the previous API.

curl -X GET -H "Content-type: application/json" -H "Accept:application/json" -H "Authorization: Bearer eyxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" https://app.testsigma.com/api/v1/execution_results/41795

The same can be done using any other REST API Client with the following details:


Request Type: GET
Request URL: https://app.testsigma.com/api/v1/execution_results/RUN_ID

Authorization: Bearer <API_KEY>

Request Header: 

Content-type: application/json
Accept:application/json


 - The RUN_ID can be obtained as value of the key 'id' in the JSON response for the previous API.

- The API_KEY can be obtained from the Configurations > API_Keys by creating a new API Key.


SCRIPT METHOD

If you want to start the Execution and then check the execution status in regular intervals you can make use of a more advanced script mentioned in the below article:

Generic Shell Script for Integrating with any CI/CD Tool


That's all we need to automate Test Execution when a successful build is triggered using the Jenkins CI server.


Welcome to the era of Smart Test Automation!


***