[英]Maven-surefire-plugin and forked mode
因此,我有一些类依赖于其中具有本机方法的jar文件。 在模拟此jar文件中的对象时遇到了问题...因此我找到了一种可行的解决方案。
使用forkedmode pertest似乎可以解决此问题。 但是,有5个文件受需要以分叉模式运行的影响...还有130个不需要分叉的测试,并且使用cobertura的构建时间非常缓慢,因为该pom中的每个测试都分叉。 ..
所以我的问题是...是否有一种方法可以指定要在派生模式下运行哪些类并正常运行其他所有类?
有没有一种方法可以指定要在派生模式下运行哪些类并正常运行其他所有类?
您可以通过指定两个具有特定<configuration>
<execution>
元素来做到这一点:对于大多数测试(不包括需要forked
那些),默认一个将forkMode
设置为once
,将一个特殊的用于特殊测试(仅包括特殊的一种),其中forkMode
设置为always
。
这是一个pom片段,显示了如何执行此操作:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<!-- Lock down plugin version for build reproducibility -->
<version>2.6</version>
<executions>
<execution>
<id>default-test</id><!-- here we configure the default execution -->
<configuration>
<forkMode>once</forkMode><!-- this is the default, can be omitted -->
<excludes>
<exclude>**/somepackage/*Test.java</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>special-test</id><!-- and here we configure the special execution -->
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<forkMode>always</forkMode>
<includes>
<include>**/somepackage/*Test.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.