I'm trying to clean up our functional suite at work and I was wondering if there is way to have cucumber repeat a scenario and see if passes before moving on to the next scenario in the feature? Phantom is my headless webkit browser poltergeist is my driver.
Basically our build keeps on failing because the box gets overwhelmed by all the test and during a scenario the page won't have enough time to render whatever it is we're trying to test. Therefore, this produces a false positive. I know of no way to anticipate what test will hang up the build.
What would be nice is to have a hook(one idea) that happens after each scenario. If the scenario passes then great print the results for that scenario and move on. However, if the scenario fails then try running it again just to make sure it isn't the build getting dizzy. Then and only then do you print the results for that scenario and move on to the next test.
Does anyone have any idea on how to implement that?
I'm thinking something like
After do |scenario|
if scenario.failed?
result = scenario.run_again # I just made this function up I know for a fact this doesn't actually exist (see http://cukes.info/api/cucumber/ruby/yardoc/Cucumber/Ast/Scenario.html)
if !result
Cucumber.wants_to_quit = true
end
end
end
The initial solution I saw for this was: How to rerun the failed scenarios using Cucumber?
This would be fine, but I would need to make sure that
cucumber @rerun.txt
actually corrected the reports if the test passed. Like
cucumber @rerun.txt --format junit --out foo.xml
Where foo.xml is the junit report that initially said that feature 1, 2 & 5 were passing while 3 and 4 were failing, but now will say 1, 2, 3, 4 & 5 are passing even though rerun.txt only said to rerun 3 and 4.
cucumber re-run
command here, but that wouldnt work for me. The tests which I have are dependent on each other due to the way the application is designed. So all my tests fails, if the second test case fails due to some reason. I was looking for a way similar to yours, that if I can run that particular scenario until it passes before going to the next? instead of using anuntil
orunless
loop in the steps. Any idea on it? – Emjey