简体   繁体   English

maven-surefire-plugin 在 SpringBoot 2.2.2.RELEASE 及更高版本中不起作用

[英]maven-surefire-plugin doesnot work in SpringBoot 2.2.2.RELEASE and above

I have used maven-surefire-plugin in my Maven project to execute the tests in parallel.我在我的 Maven 项目中使用了 maven-surefire-plugin 来并行执行测试。 everything work great.一切都很好。 When I have upgraded to SpringBoot 2.2.2.RELEASE and above, tests stop running in parallel.当我升级到 SpringBoot 2.2.2.RELEASE 及更高版本时,测试停止并行运行。 This is how I use the plugin:这就是我使用插件的方式:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0-M4</version>
        <configuration>
            <parallel>methods</parallel>
            <useUnlimitedThreads>true</useUnlimitedThreads>
        </configuration>
    </plugin>

Is there a way to execute tests in parallel?有没有办法并行执行测试? with this plug-in?用这个插件?
I have uploaded a small maven project with two modules:我上传了一个带有两个模块的小型 maven 项目:

  • a not working module with springBoot 2.2.6.RELEASE springBoot 2.2.6.RELEASE 的不工作模块
  • a working module with springBoot 1.5.9.RELEASE springBoot 1.5.9.RELEASE 的工作模块
    Both modules are identical except SprintBoot version除了 SprintBoot 版本外,这两个模块都是相同的

Creating a configuration in pom:在 pom 中创建配置:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <artifactId>junit-jupiter</artifactId>
                <groupId>org.junit.jupiter</groupId>
            </exclusion>
            <exclusion>
                <artifactId>junit-vintage-engine</artifactId>
                <groupId>org.junit.vintage</groupId>
            </exclusion>
            <exclusion>
                <artifactId>mockito-junit-jupiter</artifactId>
                <groupId>org.mockito</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.13</version>
    </dependency>

The problem here is of course that you are using JUnit 4 only.这里的问题当然是您只使用 JUnit 4。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM