Skip to content

Instantly share code, notes, and snippets.

Created January 25, 2017 09:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
A tool to count the number of test cases per feature file in order to evenly distribute them then running in parallel
require 'gherkin/parser'
require 'gherkin/pickles/compiler'
@test_case_files = []
@tags_to_ignore = ['@no_parallel', '@wip', '@bug', '@live', '@real', '@mobile', '@site']
all_feature_files = Dir.glob("./**/*.feature")
all_feature_files.each do |feature_file|
contents =
parser =
gherkin_document = parser.parse(contents)
pickles =, feature_file)
@test_cases_count = pickles.count
pickles.each do |test_case|
test_case[:tags].each do |tag|
if @tags_to_ignore.include? tag[:name]
@test_cases_count -= 1
if @test_cases_count > 0
@test_case_files.push({name: feature_file[2..-1], test_case_count: @test_cases_count})
sorted = @test_case_files.sort_by { |k| k[:test_case_count] }.reverse
puts sorted
Copy link

emanuil commented Jan 25, 2017

For more information read this blog post: Running Test In Parallel - Optimal Number Of Threads

Copy link

Do you have something similar to this in JAVA?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment