Running Tests from a Script

There are many use cases where you want to start a test from a script. A common scenario is a regular execution from a server cron job or within a CI/CD build pipeline.

The first thing you need is your personal API-key. In the Testup Web-App (https://app.testup.io) you will find the API Key under the tab “Profiles”:

Now you can use the following APIs in a shell, for example:

Run a test.

curl -X POST "https://app.testup.io/api/v1/project/run-all/<Project ID>?testsToReplay=<Test Case ID>"     
         -H "accept: */*" 
         -H "Content-Type: application/json"              
         -H "Authorization: ApiKey-v1 <APIKEY>"              
         -d "{\"message\":\"New run by curl\",\"threads\":1}"

where 

<APIKEY> is your API-key (see above),
<Project ID>  is the Project ID of your test (see URL of your project, e.g. 6607334),
<Test Case ID>  is the Test Case ID of your test (see URL of your test).
"New run by curl\" is the name of the new execution the command will create. You can change this freely.
"threads\" is the number of parallel test executions. 

This curl returns a JSON with the execution id <id>. Using this <id> you can get the status of the results:

curl -X GET "https://app.testup.io/api/v1/execution/<id>/details"              
     -H "accept: */*"              
     -H "Authorization: ApiKey-v1 <APIKEY>"

If you want to run all test cases at once, you can use

curl -X POST "https://app.testup.io/api/v1/project/run-all/<Project ID>"                
     -H "accept: */*" 
     -H "Content-Type: application/json"                
     -H "Authorization: ApiKey-v1 <APIKEY>"                
     -d "{\"message\":\"New run by curl\",\"threads\":2}"

Well done so far!

Was something unclear?

We have our own Slack workspace for your support, which you are welcome to join.