![](/img/trans.png)
[英]How can my Maven project run both JUnit and TestNG without TestNG trying to run JUnit tests?
[英]Maven skips JUnit/Spock failed tests run with TestNG
我有一个无法编译的Spock测试-尝试通过调用不存在的构造函数来创建类字段之一。
当maven-surefire-plugin
尝试在CI服务器(jenkins)上运行此测试时,将导致异常:
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: (...)
不会使整个构建失败,而是跳过该异常,并继续构建。 在这种情况下如何使构建失败?
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>
Spock 1.x仅JUnit4不支持TestNG。 Spock 2.x将需要JUnit平台。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.