Get a list of planned runs for manual tests, Gherkin tests, and suites

This flow demonstrates how to get a list of planned runs for manual tests, Gherkin tests, and tests suites.

Note: tests, runs, and releases are a technical preview. Until made public, send an HPECLIENTTYPE header with the value: HPE_REST_API_TECH_PREVIEW in your requests.

Areas: My work, Test runs, Releases

Entity relationship diagram

We need to access the following entities for this flow, and understand the relationships between these entities.

Entity Relationships in this flow Description of relationship Reference / relationship fields
Test Manual Test, Gherkin Test, Test Suite The test entity represents various types of tests, including manual, Gherkin, and automated. subtype
Run Tests can be run. run
Manual Test, Gherkin Test, Test Suite Test The manual, test, test suite, or Gherkin test is a subtype of the test entity. type
Suite Run

For test suites only:

Test suites can be run. A suite run is a combination of other test runs.

last_runs
Run Test Each run is associated with one test, or the tests in a test suite. test
Release Runs must be associated with a release. release
Suite Run A suite run is a combination of other test runs.  
Release Run Releases can be associated with runs. run

Back to top

Flow

Let's create the REST API call step-by-step.

  1. We request all runs in the workspace using the runs reference field.

    GET ../api/shared_spaces/<shared_space_id>/workspaces/1002/runs

  2. Let's now start building our query_clause.

    This query has two sets of criteria: The test type, and the status. We separate each set with a semi-colon (;), which represents the And operator.

    In this step, we are only interested in the runs for manual tests and Gherkin tests that have the planned status. This is an example of using a list node, using the logical_name field to check for a match.

    GET ../api/shared_spaces/<shared_space_id>/workspaces/1002/runs?query="status EQ {logical_name EQ 'list_node.run_status.planned'}"

  3. We want to access only the planned runs that are manual (manual tests, Gherkin tests, and test suites). We use the || to indicate an OR condition.

    GET ../api/shared_spaces/<shared_space_id>/workspaces/1002/runs?query="status EQ {logical_name EQ 'list_node.run_status.planned'};test EQ {subtype EQ 'test_manual'||subtype EQ 'gherkin_test' || subtype EQ 'test_suite'}"

The complete REST API call for this flow is: 

GET ../api/shared_spaces/<shared_space_id>/workspaces/1002/runs?query="status EQ {logical_name EQ 'list_node.run_status.planned'};test EQ {subtype EQ 'test_manual'||subtype EQ 'gherkin_test' || subtype EQ 'test_suite'}"

Back to top

Javascript example

/**
 * Flow: Get a list of *planned* manual, suite, manual Gherkin runs based on a certain filter (runs related to a specific release)
 * @param requestor
 */
function getPlannedManualTests(requestor) {
  requestor.get('/runs?query="status EQ {logical_name EQ ^list_node.run_status.planned^};' +
		'test EQ {subtype EQ ^test_manual^ || subtype EQ ^gherkin_test^ || subtype EQ ^test_suite^}"', function(error, message, runs) {
    console.info(runs);
  });
}

exports.getPlannedManualTests = getPlannedManualTests;

Back to top

See also: