因此,我有一些依赖于jar文件的类,jar文件中包含本机方法。在模拟这个jar file...so中的对象时,我遇到了一些问题,我找到了一个可行的解决方案。
使用forkedmode pertest似乎可以解决这个问题。然而,有5个文件受影响,需要在forkedmode...there中运行是130其他测试不需要分支,与cobertura和一切都是非常慢的构建时间,因为它在该pom中的每个测试分支...
所以我的问题是is...is有没有一种方法来指定你想要在forkedmode中运行哪些类,并正常运行其他所有的类呢?
发布于 2010-08-18 05:27:16
有没有办法指定你想要在forkedmode中运行哪些类,并正常运行其他所有的类?
为此,您可以指定两个具有特定<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>另请参阅
https://stackoverflow.com/questions/3506391
复制相似问题