-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add fail fast switch #906
Add fail fast switch #906
Conversation
This reverts commit 6634d25.
The --fail-fast flag causes Cucumber to exit immediately after the first | ||
scenario fails. | ||
|
||
Scenario: When a scenario fails |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The annotation @spawn
needs to be added to this scenario so that the cucumber instance started by the When
step is not executed in the same process as the cucumber instance that rake has started. This problem reminds me of "singletons considered harmful" and a quote from one of the pages return from a search of that topic: "everything that can be done with Singletons, can be done better with dependency injection". @mattwynne Cucumber.wants_to_quit
really?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah totally agreed about the use of that global state @brasmusson - it's a legacy we're living with for now but I'd love to see a PR that gets rid of it. Should be much easier now that the behaviour is all centred in the QuitFilter
.
Thank you, @brasmusson. I went ahead and added that tag. |
…to add-fail-fast-switch
Just an update - I'm working on fixing this but am unable to reproduce the failures locally (and it seems they are not consistent in Travis either). It looks like something I changed in runtime is interfering with some of the |
The wire support tests can be a bit flakey, so it might be nothing to do with you. I've been very busy lately but one of us should be able to take a good look at this soon. Thanks @danascheider! |
Merged, this should be released in 2.1, hopefully later today. Thanks again @danascheider. |
end | ||
|
||
def after_test_case(test_case, result) | ||
Cucumber.wants_to_quit = true unless result.ok? @configuration.strict? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this line. Is it a typo? If I remove the @configuration.strict?
bit all the tests pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That because there are no test with a test case with an undefined step, then the test case result is "not ok" only in strict mode, and only then shall the execution be stopped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh silly me! I'm old-school and I couldn't read the Ruby without parentheses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's OK, I just remembered recently that you didn't have to use them, so I stopped using them just for the sake of novelty, really. I meant to use them in this code.
Having given this some focus today as I merged it in, I thought of a couple of new ways to implement this feature. @tooky @brasmusson @danascheider I'm interested in your thoughts here.
I like (2) better. WDYT? |
I've gone ahead and implemented (1) #couldnthelpmyself. |
But I'd still like to consider doing (2) |
@mattwynne I actually considered implementing something like (2) to begin with. I think it's a good idea because that way the exit status could be |
@mattwynne You cannot use actual AfterStep hooks to do (2), since also hooks can fail. After hooks does not work either, since Around hook can still fail after the After hooks have executed. I think the idea of using exceptions to tell the runner that a test case has failed, is to complex - I mean the runner (I am talking about Cucumber::Core::Test::Runner) knows perfectly well if a test case has failed, it is actually passing the I do not see the problem with the quit filter (except that is uses the global |
Question for @danascheider - do you think it makes more sense to stop as soon as one test case fails, or should we continue but skip all the remaining ones (so we still get the same total number of scenarios)? |
@mattwynne - I actually like the idea of skipping all the remaining ones. I often wish RSpec did that with its |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Here are the changes I've made for the fail-fast switch in #879, @mattwynne. I ended up just setting
Cucumber.wants_to_quit
in theFailFast
report.The problem I haven't figured out how to solve is, when I run the fail_fast features, the instance of Cucumber running the test also gets its
@wants_to_quit
set totrue
, with the result that running the passingfail_fast.feature
invariably causes the entire thing to exit (with status 2, no less). I'll keep hammering away at this, so just let me know if any solutions spring readily to mind.Thanks!