-
Notifications
You must be signed in to change notification settings - Fork 466
-
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
Exceptions thrown by extensions invisible in Maven build logs #1444
Comments
OK, I know more now: It seems to be Maven-specific, because in Gradle the test is reported as failed, while in Maven it is silently ignored. I tried with https://github.com/spockframework/spock-example. Simply clone it and add these two annotations to @Unroll
@Rollup
class DataDrivenSpec extends Specification { Then run Gradle:
Maven:
Maven without the
|
@Tibor17 for Surefire and @marcphilipp for JUnit, can you maybe say something about why this might happen? This is a potentially big problem for Spock, failures not being reported in Surefire. It is super easy to reproduce, see the previous comment. |
@leonard84, I think that there might be something wrong with spock/spock-core/src/main/java/org/spockframework/runtime/SpockEngineDiscoveryPostProcessor.java Lines 50 to 55 in f03d22c
ErrorSpecNode is trying to avoid the spec node removal does not quite work for Maven. I have never looked into anything like this before, but if you are not faster than I, I am trying to dig in a little deeper.
|
If we look at @Override
@SuppressWarnings( "rawtypes" )
public boolean accept( Class testClass )
{
LauncherDiscoveryRequest discoveryRequest = request()
.selectors( selectClass( testClass.getName() ) )
.filters( includeAndExcludeFilters ).build();
TestPlan testPlan = launcher.discover( discoveryRequest );
return testPlan.containsTests();
} Somehow, for an @Override
public boolean isTest() {
return true;
} to
That looks better, and in Gradle the output stays the same as before, so superficially nothing seems to be broken. But I am not sure if this is the right change. It was just a hack, and I do not know enough about the super-classes and -interfaces implemented by |
Out of curiosity, does this only happen if you use |
As you can see in the protocols in my comments when using the Spock example project, there I was running the full build in all cases without any filtering. So the answer is: Yes, it also happens without any filtering. Please note the number of tests listed in the console logs and the Maven and Gradle commands I used to build the project. P.S.: Do you remember that a while ago when we talked about another Maven build problem with Spock which did not occur in Gradle, that I said it would be important to also have Maven integration tests? This is the second time within a short time frame that we have such cases. I am still thinking that the Spock CI build has a blind spot there. |
Prior to this commit, SpockEngineDiscoveryPostProcessor#processSpecNode creates an ErrorSpecNode (which implements org.junit.platform.engine.TestDescriptor) after catching errors thrown by extensions, which is then silently discarded by Maven Surefire because it filters for testPlan.containsTests(). Therefore, we have to make sure that containsTests returns true. An easy way to do that is to override mayRegisterTests(). Another way would be to override isTest() instead, but actually neither an error node nor a spec actually is as test, they rather can contain tests. Fixes #1444
Hi @kriegaex |
Hi @Tibor17. If you clone the tiny example project and modify one test the way I described, you get a full test run in 10 seconds. Thank you so much for answering my call to look into this, but I think I fixed it already in the merged PR. Surefire is more picky than Gradle with accepting Spock's error nodes, but the tweak I had to make was pretty easy. The harder part was to find where the exception was swallowed. So in the end it was not a Surefire problem as such but rather Spock not catering to Surefire's specific needs. Nobody noticed before, because Spock is built and tested on Gradle only. I however am using Maven, so I noticed while trying to test and debug a PR for Spock. |
Describe the bug
As mentioned first in #1437 (comment) and then in #1442 (comment), if an annotation-driven extension throws a runtime exception, e.g.
InvalidSpecException
orExtensionException
, this is not reflected in the Maven build log, not even in debug mode. So I guess that either the JUnit 5 platform (my guess) or some part in Spock is swallowing those exceptions.When running the same spec in an IDE like IntelliJ IDEA, the extension exception is shown. In Maven
and probably also in Gradle, the whole affected spec is simply not added to the test plan, i.e. it is not reported as ignored or failed at all. Update: In Gradle, the spec is reported as failed.This could affect a large number of built-in Spock extensions throwing exceptions, see the attached search log from my IDE.
To Reproduce
Add Spock annotations provoking errors to a test spec, e.g. a combination of
@Unroll
and@Rollup
on the same spec or feature method. Run it, first from an IDE, then from Maven. (Continued in "actual behaviour" section.)Expected behavior
Actual behavior
Run the spec from IntelliJ IDEA. You should see something like
Now run the same test from Maven, using a command like
mvn test -DfailIfNoTests=false -Dtest=StepwiseIterationsTest
. You should see something like:Java version
JDK 17, but I do not think it matters.
Buildtool version
The problem occurs in Maven, not in Gradle.
What operating system are you using
Windows
Dependencies
x
Additional context
x
The text was updated successfully, but these errors were encountered: