-
Notifications
You must be signed in to change notification settings - Fork 480
Description
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 or ExtensionException, 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
- The exception thrown by the extension is reported in the build log.
- The spec or feature is question is reported as a test error (not a failure, because no test was executed).
- The remaining specs or features are executed normally.
Actual behavior
Run the spec from IntelliJ IDEA. You should see something like
org.spockframework.runtime.InvalidSpecException: @Unroll and @Rollup must not be used on the same feature: run all tests with skip after first failure
at org.spockframework.runtime.extension.builtin.UnrollExtension.visitFeature(UnrollExtension.java:74)
at org.spockframework.runtime.extension.builtin.UnrollExtension.lambda$visitSpec$0(UnrollExtension.java:59)
Now run the same test from Maven, using a command like mvn test -DfailIfNoTests=false -Dtest=StepwiseIterationsTest. You should see something like:
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ perform-tests ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Java version
JDK 17, but I do not think it matters.
Buildtool version
The problem occurs in Maven, not in Gradle.
- Maven 3.8.1
- Surefire 2.22.2 or latest Surefire 3.0.0-M6-SNAPSHOT, same behaviour
- It is independent of whether the compilation is done by GMavenPlus Plugin or by Maven Compiler Plugin with Groovy-Eclipse. In my own projects I always use the latter, while the official Spock example project uses the former. The effect is the same.
What operating system are you using
Windows
Dependencies
x
Additional context
x