Import Gherkin to Models
    • Dark
      Light

    Import Gherkin to Models

    • Dark
      Light

    Article summary

    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":

    This will open the Gherkin importer:

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

    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.

    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 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 text 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.