Skip to content

Instantly share code, notes, and snippets.

@akostadinov
Created January 14, 2022 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akostadinov/ad4a2ab2852bccfd4caf1cb33b9574f2 to your computer and use it in GitHub Desktop.
Save akostadinov/ad4a2ab2852bccfd4caf1cb33b9574f2 to your computer and use it in GitHub Desktop.
Cucumber list-only filter. Will only print list of feature files that were selected for testing. Needs to be registered as a last filter.
require 'cucumber/core/filter'
# put inside features/support/
class PrintOnlyCukeFilter < Cucumber::Core::Filter.new
def test_case(test_case)
announce
print_file_for(test_case)
end
private
def announce
puts "FILTERED FILES:" unless @announced
@announced = true
end
def print_file_for(test_case)
current_file = test_case.location.file
return if current_file == @last_file
@last_file = current_file
puts test_case.location.file
end
end
AfterConfiguration do |config|
config.filters << PrintOnlyCukeFilter.new
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment