-
Notifications
You must be signed in to change notification settings - Fork 63
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
after.each only executes if examples pass #96
Comments
Seems like the issue is possibly the if stmt on line 30 in example.py:
should maybe by just:
without the if? |
…ass. There was an if statement that checked for errors and only ran code in after.each if there were none. Removed this if check.
…ass. There was an if statement that checked for errors and only ran code in after.each if there were none. Removed this if check.
Just made a pull request to fix this |
Essentially a dupe of #71 but thanks for the contribution!. I believe this is a behaviour change which would need discussion - it doesn't really feel like a bug because the |
On a side note, how come you consider your test "passed" before verifying doubles? |
Thanks for the reply! Sorry, didn't see #71. To answer your question, I use a doubles library that allows code like:
Which requires either having to call verify() in every single test, or having an after.each to put it in. Actually, it would be super helpful if there was a way to define after.each outside of specific examples so you don't have to put your teardown() call in every example of your test suite (but I saw there's already an open issue for this). If you don't mind, could you explain how it's desired behavior to have code in after.each not execute if the example fails? In my case, we're using sqlalchemy and using transactions for test isolation. This is pretty common practice I think and really requires the behavior of after.each always executing. If you're curious, we're doing something along the lines of: You could of course do something like delete all of the data out of your database in a before.each, but from experience I can say that this approach can be considerably slower than using transactions in even a modest size application with a modest sized test suite. |
Yeah! Thanks for the PR. As I said in #71 let me do some research about this stuff with rspec and others. I do not use mock + verify behaviour, and this error wasn't too painful for me. But I hope it will be resolved today. Thanks for the PR @jes5e and thanks @Angelsanz for caring :) |
Fixes issue #96 - after.each only executes if examples pass.
Awesome, thanks! |
As a heavy ruby/rspec user, I'm really happy that mamba exists. Having a couple of issues though, and this is the biggest for me:
When a test fails, the code in after.each never executes. This seems like a bug to me. In my test suite I need to do things after every test (verify doubles, roll back session, etc.), but those things only happen when a test passes. Am I missing something here?
Simple example:
The text was updated successfully, but these errors were encountered: