Get application modules whose tests recently failed

This flow demonstrates how to get a list of application modules whose automated tests failed in the last 24 hours.

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

Areas: Test runs, Application modules (product areas) 

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   The test entity represents various test subtypes, including manual, Gherkin, and automated. subtype
Automated Test Test The automated test is a subtype of the test entity. type

Each automated test can have 0 or more runs associated with it.

We will use the automated test's reference field last_runs to find the last run that occurred in the past 24 hours.

Runs Automated test Each run is associated with one test. test_of_last_run
List Each run has a status, and the statuses are stored in a list node. status
Product Area Test Tests can be associated with product areas (also known as application modules). test

Back to top


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

  1. We can start by listing all the product areas in the workspace.

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

  2. Let's build our query_clause. We are only interested in the product areas that are associated with tests whose runs failed and had run in the last 24 hours.

    This is a nested query. We will be querying for certain runs of the tests associated with the product areas in our workspace.

    This query has three sets of criteria: The last runs, the status, and the creation time. We will separate each set with a semi-colon (;), which represents the And operator.

    Let's start from the outermost clauses of the query. We will fill in the innermost query soon.

    GET .../api/shared_spaces/<shared_space_id>/workspaces/1002/product_areas?query="test EQ {last_runs EQ { inner_query }}"

  3. Now that we see how to look for the last runs of a test, we can specify which last runs we want to get by filling in the inner query. We want to access only those runs with a failed status.

    This is an example of how to work with list nodes. One of the available lists in ALM Octane is run_status, which is a list_node. We want to compare the last run's status with the run_status list's value failed.

    GET .../api/shared_spaces/<shared_space_id>/workspaces/1002/product_areas?query="test EQ {last_runs EQ {status EQ {logical_name EQ ^list_node.run_status.failed^}}}"

  4. Now we see application modules in the workspace that are associated with failed runs for automated tests. But we want to see only those application modules associated with failed runs created in the last 24 hours.

    This is an example of how to work with creation time fields. Note the format of the date. Assuming today is July 15, 2016 at 6:45, we would query for runs after July 14, 2016.

    GET .../api/shared_spaces/<shared_space_id>/workspaces/1002/product_areas?query="test EQ {last_runs EQ {status EQ {logical_name EQ ^list_node.run_status.failed^};creation_time GT ^2016-07-14T06:45:48Z^}}"

The complete REST API call for this flow is: 

GET .../api/shared_spaces/<shared_space_id>/workspaces/1002/product_areas?query="test EQ {last_runs EQ {status EQ {logical_name EQ ^list_node.run_status.failed^};creation_time GT ^2016-07-14T06:45:48Z^}}"

Back to top

Javascript example

* Flow: How to find application modules with failed tests (within the last 24 hours)
* @param requestor
function getModulesWithFailingTests(requestor) {

  requestor.get('/product_areas?query="test EQ {last_runs EQ {status EQ {logical_name EQ ^list_node.run_status.failed^};' +
    'creation_time GT ^' + getLast24HoursDateString() + '^}}"', function(error, message, product_areas) {;

exports.getModulesWithFailingTests = getModulesWithFailingTests;
function getLast24HoursDateString() {
  var date = new Date();
  date.setDate(date.getDate() - 1);

  return date.toISOString();

Back to top

See also: