Converting Gherkin Specifications to Models

< Back

The automated Gherkin importer allows you to convert Features specified in the Gherkin syntax to models in Test Modeller.  The models can then be used to automatically generate test cases, data, and automated tests, quickly moving from Behaviour-Driven requirements to rigorous testing.

To convert Gherkin specifications to models, first create a new model in your workspace, or open an existing one.

Navigate to the “Connectors” tab of the menu and select “Gherkin”:

Connectors_Gherkin_Importing Gherkin Specifications 1

This will open the Gherkin importer:

Connectors_Gherkin_Importing Gherkin Specifications 2

Type or paste one or more Gherkin scenarios into the Importer:

Connectors_Gherkin_Importing Gherkin Specifications 3

Note: You must follow the Gherkin syntax in full. The imported Feature File must have a Feature heading, and each individual scenario must be named, as shown above. Scenarios must be made up of at least one of the following steps:

  1. A “Given” – this specifies the context or state of the system;
  2. A “When” – this describes an event or action.
  3. A “Then” – this describes an expected outcome.

Scenarios can include “And” to specify several steps following the initial “Given”, “When” or “Then”.

Click “Import” to auto-generate a model from the Scenarios. A notification will let you know when the import has been completed.

Connectors_Gherkin_Importing Gherkin Specifications 4

The Importer automatically consolidates overlapping Steps. For example, in the above example the action “When I enter a valid email” appears in two scenarios; in the model, it features in one path with a decision.

This is useful for generating a set of optimised test cases (paths) that exercise all the logic specified in the Gherkin scenarios, but in as few tests as possible. A given set of paths can “cover” every block in the model, which in turn cover every step specified in the Gherkin scenarios, but without repetitiously executing every scenario as an individual step.

Once you have imported the Gherkin scenarios to a model, the full range of Test Modeller functionality is available. This includes:

  1. Improving the system design for completeness and to remove ambiguity. You can inspect the visual model for any missing logic, adding this in before development and testing. For example, in the above model, there is no scenario for testing what happens when an invalid email and invalid pass are entered. This can quickly be added to the model by connecting the relevant blocks with an arrow. The resultant test cases generated from the model will then include this functionality, more rigorously testing the log-in page specified in the model.
  2. Automatically generating a rigorous set of test cases to fully exercise the logic contained in the Gherkin scenarios. Alternatively, an optimised set of tests can be created to target certain functionality for more rigorous testing.
  3. Creating test data with which to execute every test generated from the model.
  4. Executing the test cases and data generated from the model automatically using new or existing test automation frameworks.
Next Test Data Automation for Gherkin Specifications
Table of Contents