---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# Cloud Runner TestGenerationApi -- Scoped, Global

# Cloud Runner TestGenerationApi -- Scoped, Global {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 minutes to read

Manages test job generation to be executed in a cloud runner for Automated Test Framework (ATF).
This API is part of the CloudRunnerApi script include.  
You can use this API for the following tasks:

* Start the test generation job.
* Check the progress of the test generation job.
* Cancel the test generation job.
{#cloudrnr-TestGenerationAPI-scoped__cloudrnr-TestGenerationAPI-scoped_ul_vwb_wvn_31c}

In global scope, this API is executed within the sn_atf_tg namespace. You must have the [ATF Test Generator and Cloud Runner](https://www.servicenow.com/docs/access?context=atf-tg-cr-intro&version=xanadu&pubname=xanadu-servicenow-platform&ft:locale=en-US) (sn_atf_tg) plugin activated to use this API.  
See also:

* [Cloud Runner TestRunnerApi -- Scoped, Global](https://servicenow-prod.fluidtopics.net/1f_LUhgMcRemWk6yfAOi2g#cloudrnr-TestRunnerAPI-scoped "Manages tests to be executed in a cloud runner for Automated Test Framework (ATF). This API is part of the CloudRunnerApi script include.")
* [Cloud Runner TestUserApi -- Scoped, Global](https://servicenow-prod.fluidtopics.net/XWkYqfAwSwvx_nHpgepjdA#cloudrnr-TestUserAPI-scoped "Manages test user jobs to be executed in a cloud runner for Automated Test Framework (ATF). This API is part of the CloudRunnerApi script include.")
* [Cloud Runner Test Generation REST API](https://servicenow-prod.fluidtopics.net/5qhFvUFabNBrgM2O~A8heQ#cloudrunner-testgeneration-api "Manages test job generation to be executed in a cloud runner for Automated Test Framework (ATF).")
{#cloudrnr-TestGenerationAPI-scoped__ul_gd4_zsn_31c}

## TestGenerationApi -- cancelJob(String snboqId) {#ariaid-title2}

Sets the test generation job and its associated update set record to complete status. Cancels the root trackers of any generated tests that are running. If any test jobs are in progress on cancellation, this method sets any of the in-progress test records generated to skipped.
{#cr-TestGen-cancelJob_S__table_epx_lv4_g1c__entry__3}{#cr-TestGen-cancelJob_S__cr-snboqId-ph-desc}

| Name | Type | Description |
|-|-|-|
| snboqId | String | Required. The sys_id of the BOQ record in the Browser Orchestration Queue \[sn_atf_tg_sn_boq\] table. |
[Table 1. Parameters]

{#cr-TestGen-cancelJob_S__table_epx_lv4_g1c} {#cr-TestGen-cancelJob_S__table_fpx_lv4_g1c__entry__2}

| Type | Description |
|-|-|
| null | Null if successful, error message otherwise. |
[Table 2. Returns]

{#cr-TestGen-cancelJob_S__table_fpx_lv4_g1c}  
The following example shows how to start generating tests for the incident table and cancel the test generation. In the global scope, use the sn_atf_tg namespace.

    var insertedSnboqId = CloudRunnerAPI.TestGenerationAPI.startJob({
      tableEncodedQuery: "nameISincident",
      catalogEncodedQuery: "sysIdISEMPTY",
      maxTestCount: 10
    });

    CloudRunnerAPI.TestGenerationAPI.cancelJob({snboqId: insertedSnboqId});

## TestGenerationApi -- progress(String snboqId) {#ariaid-title3}

Provides the status of each generated test for a provided Browser Orchestration Queue (BOQ) record.
{#cr-TestGen-progress_S__table_epx_lv4_g1c__entry__3}{#cr-TestGen-progress_S__cr-snboqId-ph-desc}

| Name | Type | Description |
|-|-|-|
| snboqId | String | Required. The sys_id of the BOQ record in the Browser Orchestration Queue \[sn_atf_tg_sn_boq\] table. |
[Table 3. Parameters]

{#cr-TestGen-progress_S__table_epx_lv4_g1c} {#cr-TestGen-progress_S__table_fpx_lv4_g1c__entry__2}

| Type | Description |
|-|-|
| Object | Information about the test job. You can find advanced test details in the Generated Tests \[sn_atf_tg_generated_test\] table. { "testsFailed": Number, "testsInProgress": Number, "testsPending": Number, "testsSkipped": Number, "testsSucceeded": Number } |
| testsFailed | The number of failed tests generated. The failure reasons are listed in the Generated Tests \[sn_atf_tg_generated_test\] table. Data type: Number |
| testsInProgress | The number of use cases being created. Data type: Number |
| testsPending | The number of use cases remaining to be generated. Data type: Number |
| testsSkipped | The number of tests skipped due to job cancellation. Data type: Number |
| testsSucceeded | The number of successfully generated tests. Data type: Number |
[Table 4. Returns]

{#cr-TestGen-progress_S__table_fpx_lv4_g1c}  
The following example shows how to start generating tests for the incident table, get the progress, and cancel the test generation. In the global scope, use the sn_atf_tg namespace.

    var snboqId = CloudRunnerAPI.TestGenerationAPI.startJob({
      "tableEncodedQuery": "nameISincident",
      "catalogEncodedQuery": "sysIdISEMPTY",
      "maxTestCount": 10
    });

    gs.info(JSON.stringify(CloudRunnerAPI.TestGenerationAPI.progress({snboqId: snboqId})));

    CloudRunnerAPI.TestGenerationAPI.cancelJob({"snboqId": snboqId});

Output:

    {
      "testsSucceeded": 4,
      "testsFailed": 2,
      "testsPending": 2,
      "testsInProgress": 8,
      "testsSkipped": 0
    }

## TestGenerationApi -- startJob(String tableEncodedQuery, String userEncodedQuery, String catalogEncodedQuery, Number maxTestCount, Number maxTestCountPerTable, Number maxTestCountPerItem, String email, Boolean
separateUpdateSetPerScope, String scopeForGeneratingTests) {#ariaid-title4}

Inserts a record into the Browser Orchestration Queue (BOQ) \[sn_atf_tg_sn_boq\] table to start a test job.
{#cr-TestGen-startJob_S_S_S_N_N_N_S__table_epx_lv4_g1c__entry__3}{#cr-TestGen-startJob_S_S_S_N_N_N_S__store-2024-05}

| Name | Type | Description |
|-|-|-|
| catalogEncodedQuery | String | Optional. Encoded query specifying the catalog items (CIs) on which to generate tests. Default: All CIs (empty string) |
| email | String | Optional. Email address to send a notification to when the test generation is complete. Default: No email (empty string) |
| maxTestCount | Number | Optional. Maximum number of tests to generate. Possible values: 1-9999 Default: 9999 (maximum value) |
| maxTestCountPerItem | Number | Optional. Maximum number of tests to generate per CI. Possible values: 1-10 Default: 10 (maximum value) |
| maxTestCountPerTable | Number | Optional. Maximum number of tests to generate per table. Possible values: 1-10 Default: 10 (maximum value) |
| scopeForGeneratingTests | String | Required when separateUpdateSetPerScope is set to false. Sys_id of the scope in which to place all generated tests. Default: No sys_id (empty string) |
| separateUpdateSetPerScope | Boolean | Optional. Flag that indicates whether to separate generated tests into respective suites, update sets, and scopes, or to place tests into one suite, update set, and scope. Valid values: * true: Tests are placed into their respective suite and update set according to the scope of each table or catalog item. * false: All generated tests are placed in the same suite, update set, and scope. If false, scopeForGeneratingTests is required in the request. {#cr-TestGen-startJob_S_S_S_N_N_N_S__ul_l4b_qfj_y1c} Default: true |
| tableEncodedQuery | String | Optional. Encoded query specifying the tables on which to generate tests. See [Encoded query strings](https://www.servicenow.com/docs/access?context=c_EncodedQueryStrings&version=xanadu&pubname=xanadu-platform-user-interface&ft:locale=en-US). Default: All tables (empty string) |
| userEncodedQuery | String | Optional. Encoded query specifying the users on which to generate tests. Default: All users (empty string) |
[Table 5. Parameters]

{#cr-TestGen-startJob_S_S_S_N_N_N_S__table_epx_lv4_g1c} {#cr-TestGen-startJob_S_S_S_N_N_N_S__table_fpx_lv4_g1c__entry__2}

| Type | Description |
|-|-|
| String | The sys_id of the BOQ record in the Browser Orchestration Queue \[sn_atf_tg_sn_boq\] table. |
[Table 6. Returns]

{#cr-TestGen-startJob_S_S_S_N_N_N_S__table_fpx_lv4_g1c}  
The following example shows how to start generating tests for the incident table. In the global scope, use the sn_atf_tg namespace.

    var insertedSnboqId = CloudRunnerAPI.TestGenerationAPI.startJob({
      tableEncodedQuery: "nameISincident",
      catalogEncodedQuery: "sysIdISEMPTY",
      maxTestCount: 10
    });

    gs.info(insertedSnboqId);

Output:

    <sys_id of inserted BOQ record>


