-
Notifications
You must be signed in to change notification settings - Fork 466
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
Soft asserts: check all then throw all failures #50
Conversation
+1 |
import spock.lang.AssertionMode; | ||
import spock.lang.AssertionType; | ||
|
||
public class AssertionModeExtension extends AbstractAnnotationDrivenExtension<AssertionMode> { |
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.
For a Spock user wanting to use soft assertion for the first time it would very useful to have a JavaDoc with sample usage here (with @link
from AssertionMode
and AssertionType
).
I like the simplicity of your implementation. |
update after review
Thank you @szpak . |
@pniederw Any progress? |
+1
|
@leonard84 FYI:
|
This looks like a very useful feature - what is left to do here, to have it merged and released? |
@Fuud when thinking about it a bit more, I think it is preferable to have a single annotation without an enum. Since the enum has only two values and one of them is the default behavior of the validation anyway, I don't see an advantage by using it. I think it would be more clear if the annotation would be something along the lines of |
def "null pointer exception in condition"() { | ||
when: | ||
runner.runFeatureBody( | ||
""" |
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.
Please fix the indenting (starting and closing """
should be on the same level) and use given
or setup
in the feature bodies.
It does not matter since repo owners does not want to merge it. |
I agree with @leonard84 about single annotation like |
@jirutka I would say it is like |
@leonard84 I’m not sure if we need it, just pointing to a potential limitation. Something like |
Some problems with nested scopes. For example this test fails because condition inside Closure is recored by ErrorCollector.
Will be fixed soon. |
I really want to merge this but we need to settle…
I know there's been a long delay in getting anywhere with this issue but if we have solutions to those problems I'd really like to move forward. |
I'm going to close this as we merged #557 which provides an alternate approach to the same thing. |
It worth noting that the merged approach only allows to verifyAll conditions in a single then/and block. It does not replace annotation approach, they can perfectly compromise each other.
and do not fail after the first 'then' block. This could not be achieved via verifyAll but can be achieved via annotation. |
Note: this pull-request based on #49
Idea
Lets take an example:
It fails with:
It's enougth for small and fast unit tests. But for integration tests we should provide all information that we have. So it will be better to check all conditions and report all failures. This behaviour should be enabled only if user explicitly enable it (because there can be blocking operations based on previous conditions). For example:
will be reported as
Additional rules
Other implementations