Automated Tests API

Note: requests to this Automated Tests API (v1) are depreciated, please start using API V2 – Runs instead.

Prior read: API – General

PractiTest supports the execution of both Manual and Automated Tests, allowing you to run tests from any commercial tool (e.g. Selenium, Watir, QTP, Silk, etc.) or home-grown tools.
The Automation support is available only to Enterprise License users.

There are two different ways of working with automation and PractiTest:

  • PractiTest’s API – you initialize your automated tests (via cron, scheduler, scripts, etc.), and at the end of the test you call PractiTest’s API functions to update your results.
  • PractiTest’s xBot – PractiTest helps you to schedule and run the tests via the xBot client. Click here for more information about how it works.

PractiTest Automation API main advantages:

  • Flexible – define the functions you want
  • Can be run automatically -> whether via a cron task, or when you commit, depends on your needs and configuration
  • Integrates with your existing framework
  • Define the results you want for your report
  • Initialize your automated tests (via framework) and update PractiTest with your results

Action supported

(Initial path may be https://api.practitest.com/api/v1):

 

HTTP Verb Path used for
GET /automated_tests/next_test.json first available automated test to run
POST /automated_tests/upload_test_result.json update a test with results

GET /automated_tests/next_test.json – first available automated test to run

Used mostly by xBot agent. To update existing tests via the api use upload_test_result.

Gets the first available automated test to run.

Extra (optional) parameter:
  • client_id – An id of the xbot client. Required if different xbot clients run different type of tests

Returns:

  • id -> instance system_id
  • path to application to run
  • path to update results

POST /automated_tests/upload_test_result.json – update a test with results

Update a test-instance with results.

Parameters:

  • project_id – the id of the project AND instance_display_id -> the display_id of an instance
    OR
    instance_id – the instance system_id. For example, if you click on the instance, here’s the url:
    https://prod.practitest.com/p/you_project_id/sets/testset_system_id/instances/instance_id/edit (instance_system_id = instance_id)
    OR
    project_id, testset_display_id -> the display_id of a TestSet, AND test_display_id -> the display_id of a Test from the Tests library
  • exit_code -> 0 for passed, otherwise failed
  • run_custom fields – with name and value, to update the run custom fields (look at the example below)
  • instance_custom fields – with name and value, to update the instance custom fields (look at the example below)
  • run_duration – with name and value (HH:MM:SS), to update the run duration of a specific instance
    Notices:
    * Custom fields will not be validated. For example, if you enter text in a field of type number this won’t be validated by the API, and so the value won’t be save and you will not get an error.
    ** System Field update is not supported.
  • result – text output string that will be shown in ‘Execution output’ field (up to 255 characters)
  • result_files – an hash of files to be attached to the test result (see example here)
Examples of a json hash to be sent for the instance below:
Automated tests API
Example 1: identifying the instance via instance_display_id (and project_id)
{ "project_id":3,
 "instance_display_id":"2:1",
"run_custom_fields":[{"name":"build","value":3214},{"name":"component","value":"server"}],
 "instance_custom_fields":[{"name":"browser","value":'IE9'}, {"name":"machine","value":"C3"}],"exit_code":0
}
Example 2: identifying the instance via testset_display_id and test_display_id (and project_id)
{
 "project_id":3,
 "testset_display_id":2,
"test_display_id": 223,
 "run_custom_fields":[{"name":"build","value":3214}, {"name":"component","value":"server"}],
 "instance_custom_fields":[{"name":"browser","value":'IE9'}, {"name":"machine","value":"C3"}],
"exit_code":0 }

Additional Parameters – steps, override the exit_code (additional statuses):

An array of steps can be pushed. When this happens, the “exit_code” is ignored, and the test run status is the computed status of all of its steps.

Step status can be any of the following: “FAILED”, “BLOCKED”, “PASSED”, “NOT COMPLETED”, “NO RUN”.

Example 3, sending a “BLOCKED” status to the run and instance with steps:

{
 "project_id":3,
 "testset_display_id":2,
 "test_display_id": 223,
 "steps":[
 {"name":"Login","description":"robot login","expected_results":"robot should login","status":"PASSED"},
 {"name":"Create user","description":"create a new user","actual_results":"blocked because the page is gone","status":"BLOCKED"}
 ],
 "exit_code": "WHATEVER, I AM IGNORED"
 }

Simple curl example

curl -H "Content-Type: application/json" \
     -H "Authorization: custom api_token=CHANGE_WITH_YOUR_TOKEN" \
    -X POST -d '{"instance_id":937335,"exit_code":0}' https://api.practitest.com/api/v1/automated_tests/upload_test_result.json

Curl example with steps

curl -H "Content-Type: application/json" \
     -H "Authorization: custom api_token=CHANGE_WITH_YOUR_TOKEN" \
    -X POST -d '{"instance_id":86631,"exit_code":0, "steps":[ {"name":"Login","description":"robot login","expected_results":"robot should login","status":"PASSED"}, {"name":"Create user","description":"create a new user","actual_results":"blocked because the page is gone","status":"BLOCKED"} ]}' https://api.practitest.com/api/v1/automated_tests/upload_test_result.json

Returns

  • HTTP OK if successful, otherwise it will show the error.

Code Examples

Here’s a full example of posting an ‘upload_test_result” in Python:
https://gist.github.com/1835675

Here’s a full example of posting an ‘upload_test_result” in ruby:

Here’s a full example of posting an ‘upload_test_result” in ruby:
Post results with file attachment example (Python)
<< Previous Next >>
Turn your testing data into QA intelligence now!

PractiTest – all rights reserved / The website was designed & developed by Chilid

SaaS Test Management Tool and QA Management Tools - PractiTest