Last active
July 14, 2017 11:11
-
-
Save FinnWoelm/e6f0a65d5e0f580fbba41437aa640181 to your computer and use it in GitHub Desktop.
Run (a) cucumber feature test(s) repeatedly and count successes and failures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# USAGE: | |
# $ ./repeated_feature_test.rb n test | |
# n: number of times to run the test | |
# test: the test you would like to run, such as "cucumber" or | |
# "cucumber features/posts.feature --format progress" | |
# | |
# Due to the nature of executing commands, you will not see output until the end | |
# of each test round. For example, if you set "cucumber" as the task, you will | |
# not see output until the entire cucumber test has completed once. | |
# | |
# PS: Make sure to make this script executable: | |
# chmod +x repeated_feature_test.rb | |
# | |
require 'benchmark' | |
run_spec_n_times = ARGV.shift.to_i | |
failure_count = 0 | |
total_time = Benchmark.realtime do | |
run_spec_n_times.times do |i| | |
puts "##{i+1} / #{run_spec_n_times} " + | |
"(S: #{i-failure_count} | F: #{failure_count}) " + | |
"@ #{Time.now.strftime("%F %T.%3N")}" | |
result = %x[ #{ARGV.join(' ')} ] | |
# if result has failed, lets track it | |
if result.include? "failed steps" | |
failure_count += 1 | |
end | |
printf result | |
end | |
end | |
printf "" + | |
"**************************************************************************\n" + | |
"**** REPEATED FEATURE TEST COMPLETE **************************************\n" + | |
"**************************************************************************\n" + | |
"**** Total Time: #{total_time.round(3)}s" + "\n" + | |
"**** Successes: #{run_spec_n_times - failure_count}" + "\n" + | |
"**** Failures: #{failure_count}" + "\n" + | |
"**************************************************************************\n" + | |
"**************************************************************************\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment