-
Notifications
You must be signed in to change notification settings - Fork 69
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
AssumptionViolatedException and TestAbortedException are treated incorrectly #89
Comments
Oh, thanks for reporting! Will have a look into it. |
Spock is not reporting that the feature was not executed. It doesn't seem to give any information at all indicating that the test did not run. I will continue trying to figure this out. |
As far as I can tell, it is currently impossible to know that the test did not execute. Spock code calls only |
The problematic code is in if (exception instanceof AssumptionViolatedException) {
// Spock has no concept of "violated assumption", so we don't notify Spock listeners
// do notify JUnit listeners unless it's a data-driven iteration that's reported as one feature
if (currentIteration == null || !currentFeature.isParameterized() || currentFeature.isReportIterations()) {
notifier.fireTestAssumptionFailed(failure);
}
} To fix this issue, Spock itself has to start calling the Spock listeners, not only JUnit's. At least, that's my current understanding. Maybe @pniederw could help solve this (or add a method to the Spock listeners to listen for this). |
IDEA reports in test tab AssumptionViolatedException tests as 'Test ignord'. It looks pretty logical. That's why I was surprised when I saw ignored tests in IDE as executed and passed in spock html report. Maybe Spock can just call:
|
@yeugenius, @renatoathaydes |
I would make a pull request against Spock to make sure it does what @yeugenius suggested, but I am very short on spare time right now... hope someone else can have a look at that. |
I've come up with a workaround for this issue. @Unroll
def "Can ignore test if AssumptionViolationException is thrown"() {
setup: 'this will throw AssumptionViolationException if the condition is false'
assertTestPrecondition( 'i should not be 2!', i != 2 )
expect:
i > 0
where:
i << [ 1, 2, 3 ]
} The Would that work for you @yeugenius @viastakhov @SamuelGraf ? |
Ah, nevermind, spock-reports is just a report creator... I don't want to introduce unrelated APIs. My next best suggestion is to capture invocations of the The drawbacks are:
|
Of course this is not optimal but I think it would be much better as it is now (at least for me). I wonder how IntelliJ and the gradle report deal with this because they seem to get it right (at least from my experience). Unfortunately I am a beginner and don't understand much of this. |
The tools that work, only work because they integrate with JUnit, not directly with Spock. spock-reports integrates directly with Spock, not with JUnit, and because Spock does not notify spec listeners that the test was skipped, there's no good way of knowing that. The ideal solution is to make a PR against the Spock project as I mentioned above. |
So I should change:
to
and make a merge request with spock? As I said, I am a beginner and not quite sure about what i am doing here. |
I thought of submitting a PR doing this, but it was not clear to me how to handle test iterations. Your change seems incorrect for two reasons:
There's only a This is more a feature request than a bug fix on the Spock side. |
I see, |
@SamuelGraf thanks for pushing for a fix for this :) I've opened a feature request with Spock... I know they are very careful with introducing new features, so let's see what they think about it before we proceed. |
Sorry, if I am too pushy, |
As far as I can tell, in Spock 2.0, Unfortunately, though, when the equivalent JUnit5 |
If JUnit's AssumptionViolatedException was thrown inside the test, Spock treats the test as ignored, but report will show the test as executed.
AssumptionViolatedException is a useful feature to skip tests arbitrary during the Spec execution based on input data and logic that is not available before Spec starts and so far not possible t use IgnoreIf annotation.
The text was updated successfully, but these errors were encountered: