Search code examples
automationcucumberui-automationcucumber-java

Can we list all the scenarios which fall under a Cucumber tag


I have three-four Cucumber tags (say @smoke, @testing, @test) which are randomly put on scenarios and feature files. Now, I need to list all the scenarios which fall only under smoke. Can someone please suggest a way to do this


Solution

  • You can use the dryRun=true option in CucumberOptions with tag filters in your runner to get the list of scenarios in the report. This option will not execute your features but will list them out plus check if the steps have the appropriate glue code.

    @CucumberOptions(plugin={"pretty", "html:report"}, tags={"@smoke"},  
        snippets=SnippetType.CAMELCASE,
        glue="....", features="src/test/resources/features", dryRun=true)
    

    Make sure you add the correct path of your glue code. Also the features should point to the top directory containing the feature files.

    The above should list out the any scenario containing the @smoke tag in the html report.

    But if you are looking for scenario list with only @smoke tag and not the others use this filter (tags="@smoke","~@testing","~@test").

    Point of caution, if you have Scenario Outlines they will be repeated by the number of scenarios in the examples table.