Search code examples
webdrivercucumbergherkin

Cucumber: In which order the feature tags are followed in a cucumber script?


I am facing an issue where I need to run script with three features. Let's say we have 3 feature files with tag names as @smoke1, @smoke2 and @smoke3. And I want these to be executed in that sequence.

Issue is that smoke3 is executing first and rest of them afterwards.

This is my script:

@Cucumber.Options(
    glue = { "com.abc", "cucumber.runtime.java.spring.hooks" },
    features = "classpath:",
    format = { "json", "json:target/cucumber.json" },
    tags = "@smoke1, @smoke2, @smoke3"
)
public class ex_Test extends AbstractTest { }

Solution

  • Warning: This only works in older versions of Cucumber.

    Cucumber feature files are executed in alphabetical order by path and filename. The execution order is not based on tags.

    However, if you specifically specify features, they should be run in the order declared.

    For example:

    @Cucumber.Options(features={"first_smoke.feature", "another_smoke.feature"})
    

    Should run first_smoke and then another_smoke (compared to the default which is to run in the other order.