问题描述
我正在使用JUnit Categories将集成测试与单元测试分开。 Surefire插件配置有效 - 它会跳过使用我的标记接口IntegrationTest注释的测试。
I'm using JUnit Categories to separate integration tests from unit tests. The Surefire plugin configuration works - it skips the tests annotated with my marker interface IntegrationTest.
但是,Failsafe插件不会选择集成测试。我甚至尝试指定junit47提供程序,但是在集成测试阶段运行零测试。
However, the Failsafe plugin doesn't pick the integration tests. I've even tried to specify the junit47 provider, but zero tests are run in the integration-test phase.
这是pom.xml片段:
Here is the pom.xml fragment:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
<configuration>
<groups>com.mycompany.test.IntegrationTest</groups>
<excludedGroups>com.mycompany.test.UnitTest</excludedGroups>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.12</version>
</dependency>
</dependencies>
</plugin>
以下是日志中的故障安全部分:
Here is the Failsafe part of the log:
[INFO] --- maven-failsafe-plugin:2.12:integration-test (default) @ MyProject.war ---
[INFO] Failsafe report directory: /home/stoupa/MyProject/war/target/failsafe-reports
[INFO] Using configured provider org.apache.maven.surefire.junitcore.JUnitCoreProvider
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Concurrency config is parallel='none', perCoreThreadCount=true, threadCount=2, useUnlimitedThreads=false
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
是提供者org.apache.maven.surefire.junitcore.JUnitCoreProvider可以在日志输出中看到正确的吗?
Is the provider org.apache.maven.surefire.junitcore.JUnitCoreProvider that can be seen in the log output the right one?
推荐答案
默认情况下,failsafe插件会排除各种文件。你必须覆盖它。因此,请将配置部分更改为以下内容:
By default, the failsafe plugin excludes various files. You have to override that. So change your configuration section to the following:
<configuration>
<includes>
<include>**/*.java</include>
</includes>
<groups>com.mycompany.test.IntegrationTest</groups>
<excludedGroups>com.mycompany.test.UnitTest</excludedGroups>
</configuration>
这篇关于将JUnit类与Maven Failsafe插件一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!