Share this page

# Create a Gherkin test

You can use API resources to work with ALM Octane Gherkin test entities.

In this topic:

## Overview

The tests entity is a composite, resource collection that represents all subtypes of ALM Octane tests:

| Working with these test subtypes are described in this topic: Manual tests, and their test steps Gherkin tests, and their scripts Test suites, and their manual and Gherkin tests
To work with automated tests, see Working with automated tests and pipelines.

The subtype attribute distinguishes between the test types in the test resource collection.

Work with the tests resource collection to:

- See or query all tests, regardless of subtype

- Add steps to manual tests

- Add scripts to Gherkin tests

Work with the individual resource collections (manual tests, Gherkin tests, and test suites) to focus only on those subtypes.

Back to top

## GET: Read Gherkin tests

To see all tests, regardless of test subtype: | `GET .../api/shared_spaces/<space_id>/workspaces/<workspace_id>/tests`
To see only Gherkin tests, use one of the following: | `GET .../api/shared_spaces/<space_id>/workspaces/<workspace_id>/tests?query="subtype EQ ^gherkin_test^"` `GET .../api/shared_spaces/<space_id>/workspaces/<workspace_id>/gherkin_tests`

Back to top

## POST: Create a Gherkin test

Creating a Gherkin test is similar to POSTing any other ALM Octane entity. For general details, see POST: Create instances in a collection.

However, after creating the Gherkin test, you will want to add a script to it. For details, see PUT: Add a script to a Gherkin test.

To create a Gherkin test:

We add Gherkin tests using the gherkin_tests resource collection.

This example creates a Gherkin test named My_Gherkin_Test with status (phase) 1014, which is the New phase.

    POST .../api/shared_spaces/<space_id>/workspaces/<workspace_id>/gherkin_tests

    {

       "data":  [

           {

             "phase":

              {   "id":1014,

                  "type":"phase"

              },

           "name":"My_Gherkin_Test"}]

    }

Back to top

## GET: See an existing Gherkin test script

Scripts are saved as separate resources in ALM Octane's internal repository. Access the script resource by specifying the script entity after the test ID in a REST API call.

To see an existing script for a Gherkin test:

This example displays the script for the Gherkin test whose ID is 1014.

    GET .../api/shared_spaces/<space_id>/workspaces/<workspace_id>/tests/1014/script
    {
      "creation_time": "2017-04-18T22:07:24Z",
      "last_modified": "2017-04-19T02:15:14Z",
      "script": "#Auto generated Octane revision tag\n@TID1025REV0.2.0\nFeature: Buying items in shopping cart for many users\nBackground:\n  Given: payment security system is up\n\nScenario 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  Examples:\n| customer | payment |\n| Jane Doe | Paypal |\n| Jorge Rodrigues | VISA |\n| Sally Dunn | VISA |\n| Pierre Bisset | American Express |\n| Masayoshi Horita | Cash |\n"
    }

Back to top

## PUT: Add a script to a Gherkin test

Scripts are saved as separate resources in ALM Octane's internal repository. Access the script resource by specifying the script entity after the test ID in a REST API call.

We add scripts using the tests resource collection. Adding scripts using the gherkin_tests resource collection is not supported.

When adding scripts to a Gherkin test, keep in mind that any existing script is replaced.

To add a script to the Gherkin test:

This example adds a script to the Gherkin test whose ID is 1014, and labels the revision type as minor. Revision types can be Major or Minor.

    PUT .../api/shared_spaces/<space_id>/workspaces/<workspace_id>/tests/1014/script

    {
                "script": "Feature: Buying items in shopping cart, single user\n \n\tBackground: \n\t\tGiven payment security system is up\n \n\tScenario: Julio buys items in his cart\n\t\tGiven a customer named \"Julio Brown\" \n\t\tGiven I am logged in as Julio \n\t\tGiven I have at least one item in cart\n\t\tWhen I try to buy items in my cart\n\t\tThen I should be asked for my payment method",
                "comment": "Testing shopping cart functionality.",
                "revision_type": "Minor"
    }

Back to top

https://admhelp.microfocus.com ALM Octane 8942
Tips to improve your search results... ALM Octane Help Center ALM Octane Help 23.4-24.3 All View Local Help Center View Online Help Center Version: