Maven 3 maven:使用JUnit4执行集成测试,覆盖父pom中的设置

Maven 3 maven:使用JUnit4执行集成测试,覆盖父pom中的设置,maven-3,junit4,maven-failsafe-plugin,Maven 3,Junit4,Maven Failsafe Plugin,我已经迁移到JUnit5。在我的集成测试中,我使用的是PowerMock,不幸的是它还不支持最新的JUnit版本(请参阅)。因此,我决定使用较新版本运行单元测试,该版本在父POM中定义为默认版本,并且只对JUnit4运行集成测试。我试图覆盖子POM中的插件,但测试不会执行,可能是因为测试未被识别为JUnit 4测试,因此maven failsafe插件找不到任何要执行的集成测试 父POM: <plugin> <groupId>org

我已经迁移到JUnit5。在我的集成测试中,我使用的是PowerMock,不幸的是它还不支持最新的JUnit版本(请参阅)。因此,我决定使用较新版本运行单元测试,该版本在父POM中定义为默认版本,并且只对JUnit4运行集成测试。我试图覆盖子POM中的插件,但测试不会执行,可能是因为测试未被识别为JUnit 4测试,因此maven failsafe插件找不到任何要执行的集成测试

父POM:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>3.0.0-M4</version>
            <executions>
                <execution>
                    <id>integration-tests</id>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                    <configuration>
                        <argLine>${failsafeOverridableArgLine}
                            -Djacoco-agent.destfile=${project.build.directory}/coverage-reports/jacoco-it.exec</argLine>
                        <skipTests>${skip.integration.tests}</skipTests>
                        <includes>
                            <include>**/*IntegrationTest.java</include>
                        </includes>
                    </configuration>
                </execution>
            </executions>
        </plugin>
      ...
      <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter</artifactId>
        <version>5.5.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.5.2</version>
        <scope>test</scope>
    </dependency>

org.apache.maven.plugins
maven故障保护插件
3.0.0-M4
集成测试
集成测试
验证
${failsafeOverridableArgLine}
-Djacoco agent.destfile=${project.build.directory}/coverage reports/jacoco-it.exec
${skip.integration.tests}
**/*IntegrationTest.java
...
org.junit.jupiter
朱尼特朱庇特
5.5.2
测试
org.junit.jupiter
朱尼特木星发动机
5.5.2
测试
儿童POM:

       <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>3.0.0-M4</version>
            <executions>
                <execution>
                    <id>integration-tests</id>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                    <configuration combine.self="override">
                        <argLine>${failsafeOverridableArgLine}
                            -Djacoco-agent.destfile=${project.build.directory}/coverage-reports/jacoco-it.exec</argLine>
                        <skipTests>${skip.integration.tests}</skipTests>
                        <includes>
                            <include>**/*IntegrationTest.java</include>
                        </includes>
                        <classpathDependencyExcludes>
                            <classpathDependencyExclude>org.junit.jupiter:junit-jupiter</classpathDependencyExclude>
                            <classpathDependencyExclude>org.junit.jupiter:junit-jupiter-engine</classpathDependencyExclude>
                        </classpathDependencyExcludes>
                        <additionalClasspathElements>
                            <additionalClasspathElement>${settings.localRepository}/junit/junit/4.12/junit-4.12.jar</additionalClasspathElement>
                        </additionalClasspathElements>
                    </configuration>
                </execution>
            </executions>
        </plugin>

org.apache.maven.plugins
maven故障保护插件
3.0.0-M4
集成测试
集成测试
验证
${failsafeOverridableArgLine}
-Djacoco agent.destfile=${project.build.directory}/coverage reports/jacoco-it.exec
${skip.integration.tests}
**/*IntegrationTest.java
junit.jupiter:junitjupiter
junit.jupiter:junitjupiter引擎
${settings.localRepository}/junit/junit/4.12/junit-4.12.jar

此配置正确吗?

问题已解决我需要向覆盖的插件添加以下依赖项:

          <dependencies>
                <dependency>
                    <groupId>org.apache.maven.surefire</groupId>
                    <artifactId>surefire-api</artifactId>
                    <version>3.0.0-M4</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.maven.surefire</groupId>
                    <artifactId>surefire-junit47</artifactId>
                    <version>3.0.0-M4</version>
                </dependency>
            </dependencies>

org.apache.maven.surefire
SurefireAPI
3.0.0-M4
org.apache.maven.surefire
surefire-junit47
3.0.0-M4
现在,集成测试使用junit4运行,而单元测试使用junit5运行