Skip to content

Automation with Cucumber

Compatibility with Cucumber 5 or greater

If your project uses a Cucumber version older than 5, select the Cucumber 4 technology. Otherwise, if it uses Cucumber 5 or posterior, select the Cucumber 5+ technology.

Test reference in Squash TM

Depending on the report test precision you wish to apply to your test case, you can refine it down to a feature (in the case your .feature file contains more than one feature, which is not recommended even though Cucumber allows it) or to a specific scenario.

In order to bind a Squash TM test case to a Cucumber automated test, the content of the Automated test reference field of the Automation block of a test case must have the following format:

[1] / [2] # [3] # [4]

With:

  • [1]: Name of the project on the source code repository.

  • [2]: Path and name of the Cucumber test file, from the root of the project (with the .feature extension).

  • [3]: feature name as specified in the Cucumber test file. This parameter is optional.

  • [4]: scenario name as specified in the Cucumber test file. This parameter is optional.

Example: MyRepo/path/to/my/test.feature#My feature name#My scenario name

Automated test reference and execution

The feature [3] and scenario [4] precisions in the test reference have no impact on the execution, but only on the test result determination.
So, even when defining the specific level of the feature or scenario, all tests defined in the .feature file will be executed (this means, for example, that if several Squash TM test cases point toward the same file but with different features or scenarios, then all the file tests will be executed several times).
The test reports include the traces of all executed tests. But, only the Error / Failed / Success statuses corresponding to the specific feature or scenario are used to determinate the test case result.

Info

If a scenario name is not specified, the result of each executed Squash TM test case is calculated by taking into account the individual results of each scenario included in the bound file:

  • If at least one scenario has an Error status (in case of a technical issue), the status of the execution will be Blocked.

  • If at least one scenario fails functionally and none of the other has an Error status, the status of the execution will be Failed.

  • If all scenarios succeed, the status of the execution will be Success.

No support of cucumber-junit-platform-engine

The current implementation of Squash Orchestrator uses the mvn -Dcucumber.features=path/to/mytest.feature option to specify the .feature file to be executed.
This option is not managed by cucumber-junit-platform-engine. This results in the fact that lauching a Cucumber test, in the orchestrator, executes all the tests of the Maven project.
In order to avoid this issue, the junit-vintage-engine engine must be used.

If your tests are using cucumber-junit-platform-engine, you can modify them to instead use junit-vintage-engine as described here:

  • in the pom.xml file
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit-platform-engine</artifactId>
        <version>7.2.3</version>
        <scope>test</scope>
    </dependency>
    
    should be replaced by
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>7.2.3</version>
        <scope>test</scope>
    </dependency>   
    <dependency>
        <groupId>org.junit.vintage</groupId>
        <artifactId>junit-vintage-engine</artifactId>
        <version>5.8.2</version>
        <scope>test</scope>
    </dependency>
    
  • in the test root file
    import org.junit.platform.suite.api.IncludeEngines;
    import org.junit.platform.suite.api.SelectClasspathResource;
    import org.junit.platform.suite.api.Suite;
    
    @Suite
    @IncludeEngines("cucumber")
    @SelectClasspathResource("path/to/my-feature-files")
    public class RunCucumberTest {
    }
    
    should be replaced by
    import org.junit.runner.RunWith;
    import io.cucumber.junit.Cucumber;
    
    @RunWith(Cucumber.class)
    public class RunCucumberTest {
    }
    

Using the name of a Squash TM dataset as a tag

Squash AUTOM and Squash DEVOPS are able to use the name of a Squash TM dataset as a tag value, allowing to execute a specific dataset of a Cucumber scenario.

In order to achieve this, you will have to follow these steps:

  • Fill the datasets in the Parameters tab of the test case in Squash TM.

  • Create in a Cucumber scenario as many example table as there are dataset in Squash TM test case. Annotate them with a tag corresponding to the name of a Squash TM dataset.

  • Create one line of elements in each example table to set scenario's parameters values for the dataset.

Both Community and Premium versions can use dataset names.

Example

Below is an example of a Cucumber test file and the corresponding Squash TM test case automation:

Cucumber example

Cucumber example

Cucumber example

Cucumber example

Cucumber example

Cucumber example

Generation of Allure reports with the cucumber/cucumber and cucumber5/cucumber actions

When using the cucumber/cucumber et cucumber5/cucumber actions via the piloting with a PEaC, if you want the Cucumber test results to appear in the Allure report generated for the PEaC, you need to use the JUnit reporter (possibly with other reporters).

Supported versions

Squash AUTOM and Squash DEVOPS have been validated with Cucumber-JVM 4.2.6, 5.7.0, 6.11.0, and 7.0.0. Any recent version should work properly.

Back to top