Tests API

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

Prior read: API – General

Common Parameters


  1. Entities IDs: All PractiTest’s entities, including tests have two types of ids:
    system_id – the real id of the entity in the Database.
    id – the display id of the entity. This is the id that the user see in the grid, and within the PractiTest UI.
    PractiTest API gets either system_id OR id as a parameter.
  2. User / Author: When you make actions (usually via POST/ PUT), PractiTest needs to know the current user, mostly for the history, to see who did what. In those cases, the API needs the user value. Another case is when the API assigns an test to a user. The user value can specified via two options:
    user_id (or author_id for creating an test) – PractiTest’s user_id number
    OR
    user (or author) – the email of the user
    Both the user’s email and the id are unique. Please note that the specified user needs to be a user within the project.

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

HTTP Verb Path used for
GET /tests.json Gets a list of tests
GET /tests/run_statuses_count.json Gets a run status count for tests in the project
POST /tests.json Create a new test
GET /tests/:id.json display a specific test
PUT /tests/:id.json update a specific test
DELETE /tests/:id.json delete a specific test

GET /tests.json – Gets a list of tests


Will return a list of tests, filtered by filter_id. The tests will have the fields which are defined in the filter.

Parameters:

  1. optional: filter_id : The Test Filter id
  2. optional: current_user – if the filter above has CURRENT_USER criteria, then the user must be provided either by user_id or user_email.
  3. optional: project_id – The project id; will use the first project of the account if not provided
  4. optional: pagination parameters (limit per page, page number) – look at the issues documentation for an example.

Here’s an example of the json response you may get when submitting a GET request to https://api.practitest.com/api/v1/tests.json?filter_id=3512 :

{"data": [
 {"system_id":118802,"display_id":396,"name":"Login Test","run_status":"NO RUN","last_run":"25-Aug-2013  18:17","steps_count":15,"___f_2734":{"name":"Component","value":"Web"}},
 {"system_id":121176,"display_id":400,"name":"Password failure","run_status":"PASSED","last_run":"01-Nov-2012  16:48","steps_count":7,"___f_2734":{"name":"Component","value":"Authentication"}
 ],
 "additional_data":  {"pagination": {"limit":250,"page":1,"total_entities":876 } }
 }

GET /tests/run_statuses_count.json – Gets a run status count for all tests


Will retrieve a count of number of Tests in each run status

Parameters:

  1. optional : project_id – The project id; will use the first project of the account if not provided

Here’s an example of the json response you may get when submitting a GET request to https://api.practitest.com/api/v1/tests/run_statuses_count.json :

{"Project Name":"The Big Bang Theory","Project id":741,"tests":{"PASSED":724,"FAILED":140,"NOT COMPLETED":32,"NO RUN":122,"BLOCKED":1}}


GET /tests/:id.json – display a specific test


Here’s an example of the JSON response you may get when submitting a GET request to : https://api.practitest.com/api/v1/tests/1.json
{  "id":1,
 "name":"my first test",
 "description":"full test description",
 "run_status":{"name":"Run Status","value":"PASSED"},
 "author":{"name":"Author","value":"Joel Montvelisky"},
 "assigned_to":{"name":"Assigned To","value":"Alex"},
 "created_at":{"name":"Created","value":"01-Aug-2010  16:09"},
 "updated_at":{"name":"Last Modified","value":"29-Mar-2011  16:38"},
 "priority":{"name":"Priority","value":"high"},
 "test_type":{"name":"Type","value":"defect"},
 "tags":{"name":"Tags (comma seperated)","value":"sprint23"},
 "___f_2315":{"name":"Component","value":"Client"},
 "___f_976":{"name":"Complexity","value":"Regular"},
 "___f_977":{"name":"Automated by Script","value":"true"},
 }

curl example:

curl -H "Authorization: custom api_token=YOUR_API_TOKEN"  -H "Content-Type:application/json" https://api.practitest.com/api/v1/tests/9.json

Explanation:

  • id, name, description – these fields are always shown on each test, and cannot be renamed. That’s the reason you see them and their value immediately.
  • author, assigned_to … tags – these are system fields, that can be customized for each entity, and can be renamed. So, for example:
    “author”:{“name”:”Author”,”value”:”Joel Montvelisky”} -> author is the ‘uniq_name’ of this system field, the name of it, is the “name”, and the value in this case is “Joel Montvelisky (our QA expert)
  • ___f_id – these are custom fields, that each has a name and a value. The id of each custom field may be shown on the url, when editing the custom field. As system fields, also here, we specify their name, and the value. Please note that possible values for “checkbox” custom field are “yes” and “no” only.
Look at our example in ruby (for issues, but tests is the same):

POST /tests.json – Create a new test


Creates a new test object with fields set by request body. You can create tests steps by providing an array like in the following example.
To create a new test with two steps make a post request to
https://api.practitest.com/api/v1/tests

{
 "author_id": "1",
 "name": "New Test",
 "description": "New test created from the API",
 "steps": [{
 "name": "Step1",
 "description": "Step1 description",
 "expected_results": "Expected results for step 1"
 }, {
 "name": "Step2",
 "description": "Step2 description",
 "expected_results": "Expected results for step 2"
 }]
 }

Here’s an example with curl:

curl -i -X POST -H "Authorization: custom api_token=YOUR_API_TOKEN"  -H "Content-Type:application/json" https://api.practitest.com/api/v1/tests.json -d '{ "author_id": "1",  "name": "New Test",  "description": "New test created from the API",  "steps": [{ "name": "Step1", "description": "Step1 description", "expected_results": "Expected results for step 1" },  { "name": "Step2", "description": "Step2 description", "expected_results": "Expected results for step 2" }] }'

In case of success the response will be in the following format:

 {
     "display_id":15,
 "system_id":482849
 }

And in case of an error:

{
 "error": "User was not found"
 }

Here’s a curl example with parameter: “duration_estimate”
Explanation:
duration_estimate – with name and value (HH:MM:SS), to add the estimate time of test’s duration

curl -i -X POST -H "Authorization: custom api_token=YOUR_API_TOKEN"  -H "Content-Type:application/json" https://api.practitest.com/api/v1/tests.json -d '{ "project_id": "1", "author_id": "5380",  "name": "New Test",  "description": "New test created from the API", "duration_estimate": "2:30:35" }'


PUT /tests/:id.json – update a specific test


Here’s an example of the update you may use via a put request and the following parameters to : https://api.practitest.com/api/v1/tests/1.json

{
 "system_id":214,
 "user_id": 2523,
 "name":"A better test",
 "description": "my updated description"
 "run_status":{"value":"FAILED"},
 "___f_2315":{"value":"Server"}
 }

a curl example:

curl -H "Authorization: custom api_token=YOUR_API_TOKEN"  -H "Content-Type:application/json" -X PUT https://api.practitest.com/api/v1/tests/9.json -d '{"name":"This is my new name","user_id": "25"}'


DELETE /tests/:id.json – delete a specific test


A delete request with id, or with system_id.

curl example

curl -H "Authorization: custom api_token=YOUR_API_TOKEN" -X DELETE https://api.practitest.com/api/v1/tests/9.json
<< Previous Next >>
Shift your testing Forward

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