I've a spock test that fails to compile - one of the class fields is attempted to be created by invoking a non-existing constructor.
When maven-surefire-plugin
tries to run this test on the CI server (jenkins) it results in an exception:
09:54:59 Failure in JUnit mode for class com.whatever.SomeSpec
.
Caused by: org.spockframework.util.InternalSpockError: Failed to instantiate spec
.
Caused by: java.lang.ExceptionInInitializerError
.
Caused by: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: (...)
Instead of failing the whole build this exception is skipped and build continues. How can I fail the build in such a situation?
pom.xml
conf:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<threadCount>1</threadCount>
<includes>
<include>**/Test*.java</include>
<include>**/*Test.java</include>
<include>**/*TestCase.java</include>
<include>**/*Spec.class</include>
</includes>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>2.17</version>
</dependency>
</dependencies>
</plugin>
TestNG is not supported by Spock 1.x, only JUnit4. Spock 2.x will require the JUnit Platform.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.