Skip to content

Commit

Permalink
Updated CI/CD docs (REST API) (#400)
Browse files Browse the repository at this point in the history
Updated Trigger Test Plans with different environments through APIs and deleted 54 pages which are directed to respective new links.
  • Loading branch information
bharathk08 authored Apr 24, 2024
1 parent 3362a68 commit 5935073
Show file tree
Hide file tree
Showing 59 changed files with 150 additions and 3,530 deletions.
2 changes: 1 addition & 1 deletion src/left-nav-title.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
},
"rest-api": {
"/docs/test-cases/step-types/rest-api/": "Type: REST API",
"/docs/continuous-integration/rest-api/": "REST API(Generic)"
"/docs/continuous-integration/rest-api/": "REST API (Generic)"
},
"while-loop": {
"/docs/test-cases/step-types/while-loop/": "Type: While Loop"
Expand Down
45 changes: 42 additions & 3 deletions src/pages/docs/api/test-plans.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ contextual_links:
name: "Prerequisites"
url: "#prerequisites"
- type: link
name: "Test Plan - Start Test Execution API"
url: "#test-plan---start-test-execution-api"
name: "Trigger Test Plans Using API"
url: "#trigger-test-plans-using-api"
- type: link
name: "Trigger Test Plans in Different Environments"
url: "#trigger-test-plans-in-different-environments"
- type: link
name: "Obtaining the Run ID"
url: "#obtaining-the-run-id"
Expand All @@ -37,7 +40,7 @@ You can use Testsigma API to trigger test executions remotely. This is useful wh


---
## **Test Plan - Start Test Execution API**
## **Trigger Test Plans Using API**
This endpoint allows users to trigger a Test Plan execution remotely.

|**Request Type**| POST |
Expand Down Expand Up @@ -113,6 +116,41 @@ Each Test Plan Run in Testsigma has a unique Run ID. This Run ID can be used to
---


## **Trigger Test Plans in Different Environments**

To execute a test plan with different Environments, you need to have an Environment ID. You can find the Environment ID by following the steps below.

### **Get Environment ID**

1. Navigating to **Test Data > Environments**, and click on an **Environment**.


2. On the Environment page, the <ENVIRONMENT\_ID> in the URL `https://app.testsigma.com/ui/td/88/environments/<ENVIRONMENT_ID>/details` is the ID of the environment.

![Environments](https://s3.amazonaws.com/static-docs.testsigma.com/new_images/projects/applications/ttpuapienv.png)

- For Example, if the URL is `https://app.testsigma.com/ui/td/88/environments/10/details`, the **ID** is **10**.

### **Executing Tests Plans with Different Environments**

1. Navigate to **Test Plans > Test Plan > CI/CD Integrations**, and copy **CURL request** under **REST API to integrate with other tools > REST API call to start Test Plan**.
![CURL](https://s3.amazonaws.com/static-docs.testsigma.com/new_images/projects/applications/ttpuapicurl.png)

2. Provide the Environment ID in the request body.

```
curl -X POST \
-H "Content-type: application/json" \
-H "Accept:application/json" \
-H "Authorization: Bearer <API_KEY>" \
https://app.testsigma.com/api/v1/execution_results \
-d "{\"executionId\": \"301\", \"environmentId\": \"<ENVIRONMENT_ID>\"}"
```

You can execute this CURL command in your computer's command-line interface (CLI) to trigger test plan with the environment specific to the given ID.

---

## **Obtaining the Run ID**

If the Test Plan Run was started from within the Testsigma App, the Run ID can be found from the Run Results page as shown below:
Expand Down Expand Up @@ -216,3 +254,4 @@ This endpoint allows users to get details of all Test case executions using REST
|**Request Body**|<pre>{ <br> "executionId": 268,<br> "executionResultId": 986,<br> "result": "FAILURE",<br> "status": "STATUS_COMPLETED",<br> "testCases": [<br> {<br> "testCaseId": 413,<br> "testCaseName": "03 data driven small",<br> "testCaseResultId": 7975,<br> "result": "FAILURE",<br> "isDataDrivenCase": true,<br> "iterationResults": [<br> {<br> "iterationResultId": 7963,<br> "setName": "examples",<br> "result": "SUCCESS"<br> },<br> {<br> "iterationResultId": 7976,<br> "setName": "travels",<br> "result": "FAILURE"<br> },<br> {<br> "iterationResultId": 7965,<br> "setName": "examples 1",<br> "result": "FAILURE"<br> }<br> ],<br> "testSuiteId": 197,<br> "testSuiteName": "02 DD Small",<br> "testSuiteResultId": 2295,<br> "machineId": 414,<br> "machineTitle": "machine 2",<br> "machineResultId": 2370<br> }<br> ]<br> }<pre>|

---

172 changes: 104 additions & 68 deletions src/pages/docs/continuous-integration/rest-api.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Integrate Testsigma with your CI/CD using REST API (Generic)"
metadesc: "How to integrate Testsigma with your CI/CD tool via a generic REST API"
metadesc: "Integrate Testsigma with your CI/CD tool via a generic REST API. You can trigger test plans using API and check status of the execution using the API details"
noindex: false
order: 12.12
page_id: "Integrate Testsigma with your CI/CD using REST API (Generic)"
Expand All @@ -9,117 +9,153 @@ contextual_links:
- type: section
name: "Contents"
- type: link
name: "pre-requisites"
url: "#pre-requisites"
name: "Prerequisites"
url: "#prerequisites"
- type: link
name: "How to get the Testsigma Test Plan Trigger API"
url: "#how-to-get-the-testsigma-test-plan-trigger-api"
name: "Trigger Test Plans Using API"
url: "#trigger-test-plans-using-api"
- type: link
name: "The CURL request format will look like this:"
url: "#the-curl-request-format-will-look-like-this"
name: "Check the Status of Test Plan Execution Using API"
url: "#check-the-status-of-test-plan-execution-using-api"
- type: link
name: "How to get the Testsigma Test Plan Status Check API"
url: "#how-to-get-the-testsigma-test-plan-status-check-api"
- type: link
name: "SCRIPT METHOD:"
name: "Script Method"
url: "#script-method"
- type: link
name: "Executing Tests Plans in Different Environments"
url: "#executing-tests-plans-in-different-environments"
---

---

You can integrate Testsigma with your CI/CD tool to run automated tests on builds by:

1. Making a POST request to the Testsigma Test Plan Trigger API, or
You can integrate Testsigma with your CI/CD tool and trigger test plans and check execution status using REST APIs. This article discusses how to make requests to Testsigma to trigger test plans and check status using CURL & API requests.


2. Using the Test Plan Status Check API to regularly check for the execution status of your tests, until its complete.

---
##**Pre-requisites:**
You should already have the test plan that you want to execute. See [Test plan management](https://testsigma.com/docs/test-management/test-plans/overview/)

You should also know how to [generate an API key from Settings](https://testsigma.com/docs/configuration/api-keys/) and get Test Plan ID from an existing Test Plan. If not, [please refer here](https://testsigma.com/docs/continuous-integration/get-test-plan-details/)
## **How to get the Testsigma Test Plan Trigger API**
1. Go to the specific Test Plan details page in the Testsigma tool (for the Test Plan that you want to include in your CI/CD Pipeline.)
## **Prerequisites**

- You should already have the test plan that you want to execute. See [test plan management](https://testsigma.com/docs/test-management/test-plans/overview/)

- You should also know how to [generate an API key from settings](https://testsigma.com/docs/configuration/api-keys/) and get **Test Plan ID** from an existing Test Plan. See [getting test plan details](https://testsigma.com/docs/continuous-integration/get-test-plan-details/).

2. Go to the CI/CD Integrations section on the Test Plan Details page.

3. You will see the CURL request under the ‘REST API to integrate with other tools > REST API call to start Test Plan’.
---
##**The CURL request format will look like this:**
```
curl -X POST -H "Content-type: application/json" \
-H "Accept:application/json" \
-H "Authorization: Bearer <API_KEY>"\
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:

## **Trigger Test Plans Using API**

1. Go to the specific **Test Plan Details** page in the Testsigma application (for the Test Plan that you want to include in your CI/CD Pipeline)

2. Go to the **CI/CD Integrations** section on the **Test Plan Details** page.

**Request Type:** POST
3. You will see the CURL request under the **REST API to integrate with other tools > REST API call to start Test Plan**.

**Request URL:**
### **Trigger Tests through CURL request:**

**HTML**
https://app.testsigma.com/api/v1/execution_results
```
curl -X POST -H "Content-type: application/json"
-H "Accept:application/json"
-H "Authorization: Bearer <API_KEY>" https://app.testsigma.com/api/v1/execution_results
-d "{\"executionId\": \"301\", \"environmentId\": \"<ENVIRONMENT_ID>\"}"
**Authorization:** Bearer <API_KEY>
```

**Request Header:**JavaScript
You can execute this CURL command in your computer's command-line interface (CLI).

**Content-type:** application/jsonAccept:application/json
### The same can be done using any other REST API client with the following details:

**Request Body:**

```{ "executionId":"<TEST_PLAN_ID>", "buildNo":"<BUILD_NO>"}```
| **Request Type** | POST |
|-------------------|------------------------------------------------------------|
| **Request URL** | https://app.testsigma.com/api/v1/execution_results |
| **Authorization** | Bearer <API\_KEY> |
| **Content-type** | application/json |
| **Accept** | application/json |
| **Request Body** | { <br> "executionId": "<TEST\_PLAN\_ID>", <br> "buildNo": "<BUILD\_NO>" <br> "environmentId": <ENVIRONMENT\_ID> } |


- 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](https://testsigma.com/docs/continuous-integration/get-test-plan-details/)
- 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](https://testsigma.com/docs/continuous-integration/get-test-plan-details/).

- The **<API_KEY>** is used to authenticate your user in Testsigma API. This can be obtained from the Settings> API_Keys by [creating a new API Key](https://testsigma.com/docs/configuration/api-keys/)
- The **<API\_KEY>** is used to authenticate your user in Testsigma API. This can be obtained from the **Settings > API Keys** by [creating a new API key](https://testsigma.com/docs/configuration/api-keys/).

- 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.
- 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.

---
##**How to get the Testsigma Test Plan Status Check API**

This API can be used to check the status of the Test Plan once the Test Plan execution is triggered successfully.

## **Check the Status of Test Plan Execution Using API**

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 the value of the key 'id' in the JSON response for the previous API.
This API can be used to check the status of the Test Plan using GET method once the Test Plan execution is triggered successfully. Make sure to get RUN_ID for the triggered Test Plan.

`PERL`

Perl
```
curl -X GET -H "Content-type: application/json" \
-H "Accept:application/json"\
-H "Authorization: Bearer <API_KEY>"\
https://app.testsigma.com/api/v1/execution_results/41795
curl -X GET -H \"Content-type: application/json\" \\
-H \"Accept:application/json\" \\
-H \"Authorization: Bearer <API_KEY>\" \\
https://app.testsigma.com/api/v1/execution_results/<RUN_ID>";
```

### The same can be done using any other REST API Client with the following details:
You can execute this CURL command in your computer's command-line interface (CLI).

**Request Type:** GET
**Request URL:**

HTML
### The same can be done using any other REST API client with the following details:

https://app.testsigma.com/api/v1/execution_results/<RUN_ID>
**Authorization:** Bearer <API_KEY>
**Request Header:** JavaScript

**Content-type:** application/jsonAccept:application/json

- The **<RUN_ID>** can be obtained as the value of the key 'id' in the JSON response for the previous API.
- The **<API_KEY>** can be obtained from the Settings> API_Keys by creating a new API Key.
| **Request Type** | GET |
|-------------------|-----------------------------------------------------------------------|
| **Request URL** | https://app.testsigma.com/api/v1/execution_results/<RUN\_ID> |
| **Authorization** | Bearer <API\_KEY> |
| **Content-type** | application/json |
| **Accept** | application/json |


- The **<RUN_ID>** can be obtained as the value of the key 'id' in the JSON response for the previous API.
- The **<API_KEY>** can be obtained from the **Settings > 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 [Generic Shell Script for Integrating with any CI/CD Tool.](https://testsigma.com/docs/continuous-integration/shell-script/)

That's all we need to automate Test Execution when a successful build is triggered using the CI server.
## **Executing Tests Plans in Different Environments**

To execute a test plan with different Environments, you need to have an Environment ID. You can find the Environment ID by following the steps below.

### **Get Environment ID**

1. Navigating to **Test Data > Environments**, and click on an **Environment**.


2. On the Environment page, the <ENVIRONMENT\_ID> in the URL `https://app.testsigma.com/ui/td/88/environments/<ENVIRONMENT_ID>/details` is the ID of the environment.

![Environments](https://s3.amazonaws.com/static-docs.testsigma.com/new_images/projects/applications/ttpuapienv.png)

- For Example, if the URL is `https://app.testsigma.com/ui/td/88/environments/10/details`, the **ID** is **10**.

### **Executing Tests Plans with Different Environments**

1. Navigate to **Test Plans > Test Plan > CI/CD Integrations**, and copy **CURL request** under **REST API to integrate with other tools > REST API call to start Test Plan**.
![CURL](https://s3.amazonaws.com/static-docs.testsigma.com/new_images/projects/applications/ttpuapicurl.png)

2. Provide the Environment ID in the request body.

```
curl -X POST \
-H "Content-type: application/json" \
-H "Accept:application/json" \
-H "Authorization: Bearer <API_KEY>" \
https://app.testsigma.com/api/v1/execution_results \
-d "{\"executionId\": \"301\", \"environmentId\": \"<ENVIRONMENT_ID>\"}"
```

You can execute this CURL command in your computer's command-line interface (CLI) to trigger test plan with the environment specific to the given ID.

---

## **Script Method**

If you want to start the Execution and then check the execution status in regular intervals you can make use of a [generic Shell Script for integrating with any CI/CD tool](https://testsigma.com/docs/continuous-integration/shell-script/).

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

---
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
title: "Capture Single Element Using Recorder"
metadesc: "Learn how to create one element at a time using the Testsigma mobile inspector for an android project in Testsigma application."
metadesc: "Learn how to create single element at a time using the Testsigma test recorder for an android project in Testsigma application."
noindex: false
order: 6.32
page_id: "Create One Element at a Time (Using Mobile Inspector) for an Android Project"
page_id: "Create Single Element for an Android Application"
warning: false
contextual_links:
- type: section
Expand Down

This file was deleted.

Loading

0 comments on commit 5935073

Please sign in to comment.