Surefire forkMode 导致仅将最后一个测试记录在 TestSuite.txt 中

发布于 2024-09-25 05:37:54 字数 1074 浏览 0 评论 0原文

当我执行“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒儿 2024-10-02 05:37:54

到目前为止,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文