Get and update Gherkin tests that are ready for automation

This flow demonstrates:

Note: tests 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, Gherkin tests 

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 types of tests, including manual, Gherkin, and automated. subtype
Gherkin Test Test The Gherkin test is a subtype of the test entity. type
User A Gherkin test can be assigned an owner. owner
List Node A Gherkin test has an automation status, such as Ready for Automation, Requires Update, or Automated. automation_status

Back to top

Flows

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

List my Gherkin tests that are ready to automate

  1. We can start by listing all the Gherkin tests in the workspace.

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

  2. Let's build our query_clause. We are only interested in Gherkin tests that are assigned to me, and my ID is 1001.

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

    GET .../api/shared_spaces/<shared_space_id>/workspaces/1002/gherkin_tests?query="owner EQ {id EQ 1001}"

  3. We also want to query the automation status to see which Gherkin tests are ready. This is an example of how to work with list nodes. One of the available lists in ALM Octane is automation_status, and we want to compare the Gherkin test's status with the automation_status list's value ready_for_automation. We use the logical_name field to check the list of automation statuses.

    GET .../api/shared_spaces/<shared_space_id>/workspaces/1002/gherkin_tests?query="owner EQ {id EQ 1001};automation_status EQ {logical_name EQ ^list_node.automation_status.ready_for_automation^}"

The complete REST API call for this part of the flow is: 

GET .../api/shared_spaces/<shared_space_id>/workspaces/1002/gherkin_tests?query="owner EQ {id EQ 1001};automation_status EQ {logical_name EQ ^list_node.automation_status.ready_for_automation^}"

Back to top

Update the script of a Gherkin test

Assuming the first part of this flow returns one Gherkin test that is ready for automation, we now use that ID to update the script. In this flow, the ID of 1005.

PUT .../api/shared_spaces/<shared_space_id>/workspaces/1002/tests/1005/script

We PUT the following body, which contains the updated script. We make sure the script conforms to Gherkin standards.

{"script":"#Auto generated NGA revision tag\n@TID1005REV0.2.0\nFeature: Buying items in shopping cart for many users\nBackground:\n Given: payment security system is up\n\nFlow Outline: Many users buy items in their carts\nGiven a customer named <customer>\nGiven I am logged in as <customer>\nGiven I have at least one item in cart\nWhen I try to buy items in my cart\nThen I confirm my payment method <payment> and proceed to checkout.\n\n","comment":"","revisionType":"Minor"}

Back to top

See also: