Get and update Gherkin tests that are ready for automation

The following flow demonstrates how to get a list of Gherkin tests that are assigned to a developer and ready for automation.

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
Tests   This aggregate resource collection represents types of tests, including manual, Gherkin, test suites, and automated. subtype
Gherkin Test Test

The Gherkin test is a subtype of the tests aggregate resource collection.

The Gherkin test can also be accessed in the gherkin_tests resource collection.

There is no field that relates back to the aggregate resource collection, tests.

 
Workspace 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/<space_id>/workspaces/<workspace_id>/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/<space_id>/workspaces/<workspace_id>/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/<space_id>/workspaces/<workspace_id>/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/<space_id>/workspaces/<workspace_id>/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

Note: This part of the flow is provided for demonstration purposes. Generally, the user to update the script of a Gherkin test is most likely to be a business analyst that would perform this action using the ALM Octane UI.

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/<space_id>/workspaces/<workspace_id>/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\n
                    
                
                    
                             Feature: Buying items in shopping cart for many users\n
                    
                
                    
                             Background:\n  Given: payment security system is up\n\n
                    
                
                    
                             Flow Outline: Many users buy items in their carts\n
                    
                
                    
                                Given a customer named <customer>\n
                    
                
                    
                                Given I am logged in as <customer>\n
                    
                
                    
                                Given I have at least one item in cart\n
                    
                
                    
                                When I try to buy items in my cart\n
                    
                
                    
                                Then I confirm my payment method <payment> and proceed to checkout.\n\n",
                    
                
                    
                          "comment":"Testing shopping cart.",
                    
                
                    
                          "revision_type":"Minor"
                    
                
                    
                        }
                    
                

Back to top

See also: