简体   繁体   English

maven-surefire-plugin不会运行并行测试

[英]maven-surefire-plugin doesn't run parallel tests

I have a project Serenity+Java+JUnit and I try to run my tests in parallel. 我有一个项目Serenity + Java + JUnit,我尝试并行运行我的测试。 I paste this into my pom and after mvn integration-test , it is still run in a chain :( What I have done wrong? 我将它粘贴到我的pom中并在mvn integration-test ,它仍然在链中运行:(我做错了什么?

      <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.16</version>
            <configuration>
                <parallel>all</parallel>
                <forkMode>perthread</forkMode>
                <threadCount>4</threadCount>
            </configuration>
        </plugin>

Have resolved it by adding another plugin instead of surefire-plugin 通过添加另一个插件而不是surefire-plugin解决了它

         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.19.1</version>
            <configuration>
                <forkCount>5</forkCount>
                <reuseForks>true</reuseForks>
                <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
                <systemPropertyVariables>
                    <databaseSchema>MY_TEST_SCHEMA_5</databaseSchema>
                </systemPropertyVariables>
                <workingDirectory>FORK_DIRECTORY_5</workingDirectory>
            </configuration>
        </plugin>

Not really sure if what your answer suggests is correct. 不确定你的答案是否正确。 You have placed concurrency configuration in Maven Failsafe, a plugin which is responsible for safely terminating the test execution once an exception has occurred therein. 您已在Maven Failsafe中放置了并发配置,这是一个插件,负责在其中发生异常时安全地终止测试执行。 Although, as you claim it this has resolved your issue, it might impact your project in the long run. 虽然,正如您声称这已解决了您的问题,但从长远来看,它可能会影响您的项目。

According to Maven's website , the below code should be placed under Maven Surefire configuration. 根据Maven的网站 ,下面的代码应该放在Maven Surefire配置下。

<forkCount>5</forkCount>
<reuseForks>true</reuseForks>
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>

Having followed these guidelines, I was able to successfully run tests in parallel with only updating Surefire plugin. 遵循这些指导原则,我能够成功运行测试,只更新Surefire插件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么需要定义maven-surefire-plugin才能运行测试 - Why maven-surefire-plugin needs to be defined for the tests to be run AssertJ 自定义方面不适用于 maven-surefire-plugin - AssertJ custom Aspects doesn't work with maven-surefire-plugin 在并行模式下使用maven-surefire-plugin时如何识别慢速单元测试? - How to identify slow unit tests when using maven-surefire-plugin in parallel mode? 为什么maven-surefire-plugin跳过带有日志消息“因为已经为此配置运行了”的测试? - Why maven-surefire-plugin skip tests with log message “because it has already been run for this configuration”? Maven-surefire-plugin测试在Jenkins构建中失败,但在本地成功运行? - Maven-surefire-plugin tests fail in Jenkins build but run successfully locally? 使用maven-surefire-plugin的并行执行会引发PluginResolutionException - Parallel execution with maven-surefire-plugin is throwing PluginResolutionException 带有Maven-surefire-plugin的UnsatisfiedLinkError - UnsatisfiedLinkError with maven-surefire-plugin mvn 依赖:go-offline 不下载 maven-surefire-plugin 的要求 - mvn dependency:go-offline doesn't download the requirements for maven-surefire-plugin 为什么maven-surefire-plugin会在我的集成测试中运行 - Why maven-surefire-plugin would run on my integration test Spring Boot 无法运行 maven-surefire-plugin ClassNotFoundException org.apache.maven.surefire.booter.ForkedBooter - Spring Boot fails to run maven-surefire-plugin ClassNotFoundException org.apache.maven.surefire.booter.ForkedBooter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM