Cucumber keeps executing even after a step definition has failed, and it outputs not only the failing steps, but also the passing ones. What option do I need to use in order to ensure that Cucumber stop executing as soon as it has encountered a failing step?
This is my cucumber.yml file
<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
%>
default: <%= std_opts %> features
wip: --tags @wip:3 --wip features
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
autotest: <%= std_opts %> features --color
Cucumber skips all steps after a failed step by design. Once a step has failed, the test has failed and there should be no reason to perform the next steps. If you have a need to run the additional steps, likely your scenario is testing too many different things at once.
Pressing Ctrl + C and Ctrl + C twice. It should stop immediately.
To fail a scenario you just need an assertion to fail, no need to set the status of the scenario. Cucumber will take care of that if an assertion fails. For testng you can use the SoftAssert class - http://testng.org/javadocs/org/testng/asserts/SoftAssert.html You will get plenty tutorials for this.
If you use the conditional statement like "If", then you have a control to tell cucumber not to stop. and you can dictate whether a particular condition is a pass or a failure.. Now cucumber might have some library functions that can you help you with this situation.
After do |s|
# Tell Cucumber to quit after this scenario is done - if it failed.
Cucumber.wants_to_quit = true if s.failed?
end
The recommended way is using a cucumber hook, though.
This lets fail fast be invoked from the command line:
# `FAST=1 cucumber` to stop on first failure
After do |scenario|
Cucumber.wants_to_quit = ENV['FAST'] && scenario.failed?
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With