TeamCity

 + Endtest

You can use our Endtest API in order to integrate Endtest with JetBrains TeamCity.

Instructions

You can use our Endtest API in order to integrate Endtest with JetBrains TeamCity.

  1. Go to your project in TeamCity and select Edit Configuration Settings > Build Steps > Add Build Step.
  2. Select Command Line from the Runner type dropdown.
  3. Select Custom Script from the Run dropdown.
  4. In the Custom script text area, add your platform-specific script which calls the Endtest API request for starting a test execution and fetches the results.

This can be done by creating a test.sh file and executing it inside your TeamCity builds.

test.sh

#!/bin/bash
hash=$(curl -X GET --header "Accept: */*" "${3}")
for run in {1.."${4}"}
do
  sleep 30
  result=$(curl -X GET --header "Accept: */*" "https://app.endtest.io/api.php?action=getResults&appId=${1}&appCode=${2}&hash=${hash}&format=json")
  if [ "$result" == "Test is still running." ]
  then
    status=$result
    # Don't print anything
  elif [ "$result" == "Processing video recording." ]
  then
    status=$result
    # Don't print anything
  elif [ "$result" == "Stopping." ]
  then
    status=$result
  elif [ "$result" == "Erred." ]
  then
    status=$result
    echo $status
  elif [ "$result" == "" ]
  then
    status=$result
    # Don't print anything
  else
     echo "$result" | jq
     exit 0
  fi
done
exit

This sample script would require the following arguments:

  1. The App ID for your account.
  2. The App Code for your account.
  3. The API Request for starting the test execution.
  4. The number of times the API request for fetching the results will be sent once every 30 seconds.

For example, if you know that your test execution usually takes 3 minutes, you should use the value 7.

7 x 30 seconds = 210 seconds > 3 minutes

Don't forget to make your Shell script executable by running the following command:

sudo chmod +x test.sh

And you would also need to install the jq package:

sudo apt-get install jq

The command for running the sample Shell script would have the following format:

./test.sh app-id app-code api-request-to-start-test-execution number-of-loops

Let's pretend we have the following values:

App ID = 44233559

App Code = 22381137

Endtest API Request to start test execution = "https://app.endtest.io/api.php?action=runWeb&appId=44233559&appCode=22381137&suite=380667&platform=windows&os=windows10&browser=chrome&browserVersion=latest&resolution=1280x1024&geolocation=sanfrancisco&cases=all&notes="

Number of loops = 10

The command for running the sample Shell script would look like this:

./test.sh 44233559 22381137 "https://app.endtest.io/api.php?action=runWeb&appId=44233559&appCode=22381137&suite=380667&platform=windows&os=windows10&browser=chrome&browserVersion=latest&resolution=1280x1024&geolocation=sanfrancisco&cases=all&notes=" 10

The JSON with the results contains the following keys:

  • test_suite_name {string} - The name of the test suite.
  • configuration {string} - The configuration of the machine or mobile device on which the test was executed.
  • test_cases {int32} - The number of test cases.
  • passed {int32} - The number of assertions that have passed.
  • failed {int32} - The number of assertions that have failed.
  • errors {int32} - The number of errors that have been encountered.
  • start_time {timestamp} - The timestamp for the start of the test execution.
  • end_time {timestamp} - The timestamp for the end of the test execution.
  • detailed_logs {string} - The detailed logs for the test execution.
  • screenshots_and_video {string} - The URLs for the screenshots and the video recording of the test execution.

You can also use the value of the hash variable to generate the link to the Results page for that test execution:

results=https://app.endtest.io/results?hash="$hash"

You can find more details about our API in the Endtest API chapter.