REST APIs

Tricentis Test Automation for ServiceNow has several REST APIs to make integrations easier with third party tools. Here are the current API endpoints.

Authentication

For authenticated endpoints Basic Authentication is used per the ServiceNow standards for Scripted REST APIs. Please note, for enhanced capabilities with third party systems the default behavior for a Trigger endpoint is to ignore authentication. This was done purposely to avoid forcing third party tools to store credentials as part of the URL. This property may be enabled.

Endpoints

Execute Tests For Source

Executes all Test Cases related to the Source Record ID by a Test Case Source.

Request

POST

/api/x_cerso_capio/Tricentis Test Automation for ServiceNow/executeTest/:sourceType/:id

Path Parameters

sourceType

A valid source type descriptor.

source - Uses the Test Case Source relationship to find relevant test cases
CUSTOM - Additional source types may be created to override the default behavior. See Custom Source Types section.

id

A unique identifier used to look up the source type. Typically the sys ID of the related record such as a Story or Configuration record.

Body Parameters

configurationGroup

Optional The sys ID of a configuration group to execute. If none is provided ‘Default’ will be used.

Response

An array of Test Run execution sys IDs.

Example

This example will run all tests associated with the Story (99e79ae11bc95810b556ece66e4bcb5f).

Request

POST https://INSTANCE.service-now.com/api/x_cerso_capio/Tricentis Test Automation for ServiceNow/executeTest/source/99e79ae11bc95810b556ece66e4bcb5f

Response

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
[
    "78aec4f31b81dc10b556ece66e4bcb85",
    "f8aec4f31b81dc10b556ece66e4bcb9f"]

Custom Source Types

You may override the default lookup behavior by creating a Custom Source Type Script Include and referencing the source type in the request.

Custom Source Types should be Global Script include that implements an execute interface which returns an array of Test Case sys IDs.

Example Custom Source Type Script

var CapioSourceTest = Class.create();

CapioSourceTest.prototype = {
    execute: function(id) {
        // Do a lookup of Test Cases using ID then return their IDs
        return ['076191641b25c4107bfc4227cc4bcb18'];
    },

    type: 'CapioSourceTest'
};

Request

POST https://INSTANCE.service-now.com/api/x_cerso_capio/Tricentis Test Automation for ServiceNow/executeTest/CapioSourceTest/99e79ae11bc95810b556ece66e4bcb5f

Response

[
    "78aec4f31b81dc10b556ece66e4bcb85"]

Get Run Status

Gets a complete status object for a Test Run.

Request

GET

/api/x_cerso_capio/Tricentis Test Automation for ServiceNow/runStatus/:id

Path Parameters

id

A Test Run ID to return the status of

Response

A full object with a test_run property containing all the Test Run properties and a results property which contains a passing and failing object if needed which contain an array of Test Cases that failed and their results.

Example

This example will get the status for a Test Run (4e7e8e791b011c10287d415fad4bcbd8).

Request

POST https://INSTANCE.service-now.com/api/x_cerso_capio/Tricentis Test Automation for ServiceNow/runStatus/4e7e8e791b011c10287d415fad4bcbd8

Response

{
    "test_run": {
        "parent": "MB Test - Vault Test",
        "parent_value": "2e7088551bc19810287d415fad4bcb7c",
        "firefox": "false",
        "firefox_value": "false",
        "pending": "0",
        "pending_value": "0",
        "included_environments": "Madrid",
        "included_environments_value": "7aff699adb5feb803c6df00ebf96193b",
        "description": "A plan made for experimenting.",
        "description_value": "A plan made for experimenting.",
        "run_as": "test.admin",
        "run_as_value": "026b841cdb7d13803c6df00ebf961903",
        "sys_updated_on": "2020-05-28 14:04:50",
        "sys_updated_on_value": "2020-05-28 21:04:50",
        "started_by_schedule": "",
        "started_by_schedule_value": "",
        "timeout": "",
        "timeout_value": "",
        "skipped": "",
        "skipped_value": "",
        "duration": "3,180",
        "duration_value": "3180",
        "result": "Passed",
        "result_value": "Passed",
        "number": "CTR0001067",
        "number_value": "CTR0001067",
        "test_environment": "Madrid",
        "test_environment_value": "7aff699adb5feb803c6df00ebf96193b",
        "sys_id": "4e7e8e791b011c10287d415fad4bcbd8",
        "sys_id_value": "4e7e8e791b011c10287d415fad4bcbd8",
        "capability": "Functional",
        "capability_value": "Functional",
        "sys_updated_by": "test.admin",
        "sys_updated_by_value": "test.admin",
        "passes": "1",
        "passes_value": "1",
        "sys_created_on": "2020-05-28 14:04:14",
        "sys_created_on_value": "2020-05-28 21:04:14",
        "end": "",
        "end_value": "",
        "validations": "0",
        "validations_value": "0",
        "browser_height": "",
        "browser_height_value": "",
        "run_status": "Complete",
        "run_status_value": "complete",
        "started_by": "Michael ",
        "started_by_value": "ec2a9e661bf89010b556ece66e4bcbc0",
        "sys_created_by": "michael.brooks",
        "sys_created_by_value": "michael.brooks",
        "internet_explorer": "false",
        "internet_explorer_value": "false",
        "screenshot_each_step": "false",
        "screenshot_each_step_value": "false",
        "cases": "1",
        "cases_value": "1",
        "failures": "0",
        "failures_value": "0",
        "chrome": "false",
        "chrome_value": "false",
        "start": "",
        "start_value": "",
        "sys_mod_count": "6",
        "sys_mod_count_value": "6",
        "browser_width": "",
        "browser_width_value": "",
        "sys_tags": "",
        "sys_tags_value": "",
        "version": "Madrid",
        "version_value": "Madrid",
        "configuration_group": "Default",
        "configuration_group_value": "ccd11c53db56fb403c6df00ebf9619f8",
        "tests": "",
        "tests_value": "",
        "application": "ServiceNow",
        "application_value": "ServiceNow",
        "triggering_test_run": "",
        "triggering_test_run_value": "",
        "name": "MB Test - Vault Test",
        "name_value": "MB Test - Vault Test",
        "report": "",
        "report_value": "",
        "ouput": "",
        "ouput_value": ""    },
    "results": {
        "passing": [
            {
                "parent": "Expand Application - Incident",
                "parent_value": "61c5f4651b01d810287d415fad4bcb35",
                "data": "",
                "data_value": "",
                "sys_updated_on": "2020-05-28 14:04:45",
                "sys_updated_on_value": "2020-05-28 21:04:45",
                "error": "",
                "error_value": "",
                "duration": "3180.0",
                "duration_value": "3180.0",
                "result": "Passed",
                "result_value": "Passed",
                "execute_condition": "",
                "execute_condition_value": "",
                "number": "CTCI0002978",
                "number_value": "CTCI0002978",
                "sys_id": "8a7e063d1b011c10287d415fad4bcb46",
                "sys_id_value": "8a7e063d1b011c10287d415fad4bcb46",
                "sys_updated_by": "test.admin",
                "sys_updated_by_value": "test.admin",
                "advanced_execute_condition": "false",
                "advanced_execute_condition_value": "false",
                "environment_is": "",
                "environment_is_value": "",
                "sys_created_on": "2020-05-28 14:04:14",
                "sys_created_on_value": "2020-05-28 21:04:14",
                "state": "active",
                "state_value": "active",
                "sys_created_by": "michael.brooks",
                "sys_created_by_value": "michael.brooks",
                "order": "100",
                "order_value": "100",
                "actual": "",
                "actual_value": "",
                "test_suite": "CTSI0001143",
                "test_suite_value": "027e063d1b011c10287d415fad4bcb43",
                "expected": "",
                "expected_value": "",
                "environment_includes": "",
                "environment_includes_value": "",
                "sys_mod_count": "1",
                "sys_mod_count_value": "1",
                "sys_tags": "",
                "sys_tags_value": "",
                "script": "vault.read('/cubbyhole/foobar');\r\nclient.expandApplication('Incident');",
                "script_value": "vault.read('/cubbyhole/foobar');\r\nclient.expandApplication('Incident');",
                "secondary_order": "0",
                "secondary_order_value": "0",
                "environment": "",
                "environment_value": "",
                "name": "Expand Application - Incident",
                "name_value": "Expand Application - Incident",
                "previous_case_must_pass": "false",
                "previous_case_must_pass_value": "false",
                "all_cases_must_pass": "false",
                "all_cases_must_pass_value": "false",
                "validations": [],
                "results": [
                    {
                        "actual": "",
                        "actual_value": "",
                        "expected": "",
                        "expected_value": "",
                        "sys_mod_count": "0",
                        "sys_mod_count_value": "0",
                        "error_line": "2",
                        "error_line_value": "2",
                        "sys_updated_on": "2020-05-28 14:04:45",
                        "sys_updated_on_value": "2020-05-28 21:04:45",
                        "error": "",
                        "error_value": "",
                        "sys_tags": "",
                        "sys_tags_value": "",
                        "duration": "3180",
                        "duration_value": "3180",
                        "result": "passed",
                        "result_value": "passed",
                        "sys_id": "299e0ab51b459810b556ece66e4bcb2d",
                        "sys_id_value": "299e0ab51b459810b556ece66e4bcb2d",
                        "sys_updated_by": "test.admin",
                        "sys_updated_by_value": "test.admin",
                        "sys_created_on": "2020-05-28 14:04:45",
                        "sys_created_on_value": "2020-05-28 21:04:45",
                        "browser": "firefox",
                        "browser_value": "firefox",
                        "test_case_instance": "Expand Application - Incident",
                        "test_case_instance_value": "8a7e063d1b011c10287d415fad4bcb46",
                        "sys_created_by": "test.admin",
                        "sys_created_by_value": "test.admin"                    }
                ]
            }
        ],
        "failing": []
    }
}

Trigger

Trigger will execute a given trigger.

Request

POST

/api/x_cerso_capio/Tricentis Test Automation for ServiceNow/trigger/:triggerId

Path Parameters

triggerId

The ID of a Trigger as found on the Test Plan Triggers table.

Body Parameters

Additional Body Parameters can be passed and are accessible in the Trigger Advanced Condition script.

Response

An object with state and testRunID properties.
In the case of an error the state will be error or exception.

Example

This example will run all tests associated with the Trigger (ca6b5d02db1b23800bc09c27db96192d).

Request

POST https://INSTANCE.service-now.com/api/x_cerso_capio/Tricentis Test Automation for ServiceNow/trigger/ca6b5d02db1b23800bc09c27db96192d

Response

{
  "state": "ready",
  "testRunId": "78aec4f31b81dc10b556ece66e4bcb85"}

Using Advanced Condition Scripts to Control Execution Behavior

When started via a Trigger API Request the Advanced Condition script of a trigger can be used to alter test behavior.

From within the Advanced Script users will have access to three properties from the original request path, bodyand query which are all objects containing the original request parameters if they exist.

The Advanced Script can simply return a value by setting the last line of the script to a true or false value or the Advanced Script can return an object with additional properties to alter test behavior.

Example

Creating an Advanced Condition script to return a boolean.

var result = false;
// Evaluate some conditions
result = true;

// return the value by setting the last line to the value
result;

Example

Creating an Advanced Condition to return a boolean and pass some parameters via a request

Request
POST https://INSTANCE.service-now.com/api/x_cerso_capio/Tricentis Test Automation for ServiceNow/trigger/ca6b5d02db1b23800bc09c27db96192d

BODY
{
  "myProperty" : true
}
Advanced Condition Script
var result = false;
// Evaluate some conditions
result = body.myProperty;

// return the value by setting the last line to the value
result;
Response
{
  "state": "ready",
  "testRunId": "78aec4f31b81dc10b556ece66e4bcb85"}

Example

Creating an Advanced Condition to return an object and pass some parameters via a request.

Request
POST https://INSTANCE.service-now.com/api/x_cerso_capio/Tricentis Test Automation for ServiceNow/trigger/ca6b5d02db1b23800bc09c27db96192d

BODY
{
  "myProperty" : true
}
Advanced Condition Script

Only answer is required.

var result = false;
// Evaluate some conditions
result = {
  "answer" : body.myProperty,      // answer is true to execute the test
  "delay" : "1970-01-01 01:00:00", // delay execution by 1 hour
  "suites" : "All",                // an array of suite sys IDs or the string All
  "overrides": {                   // an object with configuration option overrides
    "options": {
       "timeout": 180000
    }
  }
}

// return the value by setting the last line to the value
result;
Response
{
  "state": "ready",
  "testRunId": "78aec4f31b81dc10b556ece66e4bcb85"}