Surefire forkMode 导致仅将最后一个测试记录在 TestSuite.txt 中
当我执行“mvn test”时,我的 pom.xml 中有以下内容
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<excludes>
<!-- exclude integration tests -->
<exclude>**/IT*.java</exclude>
</excludes>
<!-- Enable the following for Cassandra unit test
support -->
<forkMode>pertest</forkMode>
</configuration>
</plugin>
,最后我只在最后一次测试运行的 TEST-TestSuite.txt 中获得结果。
我确实希望启用分叉,因为我正在测试一些 Cassandra 交互,并且我想进行间歇性数据库清理。
$ mvn -version
Apache Maven 2.2.1 (r801777; 2009-08-06 15:16:01-0400)
Java version: 1.6.0_18
Java home: /usr/java/jdk-1.6.0_18/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.32-24-generic" arch: "amd64" Family: "unix"
I have the following in my pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<excludes>
<!-- exclude integration tests -->
<exclude>**/IT*.java</exclude>
</excludes>
<!-- Enable the following for Cassandra unit test
support -->
<forkMode>pertest</forkMode>
</configuration>
</plugin>
when I execute 'mvn test', in the end I only get results in TEST-TestSuite.txt for the last test run.
I do want forking enabled because I'm testing some Cassandra interactions and I'd like to do intermittent database cleanup.
$ mvn -version
Apache Maven 2.2.1 (r801777; 2009-08-06 15:16:01-0400)
Java version: 1.6.0_18
Java home: /usr/java/jdk-1.6.0_18/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.32-24-generic" arch: "amd64" Family: "unix"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
到目前为止,Surefire/TestNG 组合似乎根本不支持这一点。我改用 JUnit 进行测试/集成测试,并收到了我想要的功能。对我来说最大的损失是丢失了 @Test(priority) 注释,但我只是重新构建了我的测试来解决这个问题。
So far, it appears that the Surefire/TestNG combination simply does not support this. I switched to using JUnit for my tests/integration-tests and have received the functionality I wanted. The biggest loss for me was losing the @Test(priority) annotation, but I've simply restructured my tests to account for that.