Reputation: 391
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
Upvotes: 1
Views: 1983
Reputation: 18594
You can write your own filter to print what you would run but run nothing.
require 'cucumber/core/filter'
# put inside features/support/
class PrintOnlyCukeFilter < Cucumber::Core::Filter.new
def test_case(test_case)
puts test_case.location.to_s
end
end
AfterConfiguration do |config|
config.filters << PrintOnlyCukeFilter.new
end
Put the file in features/support
.
To print only file names you can see this gist.
Upvotes: 0
Reputation: 9058
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.
Upvotes: 1