【发布时间】:2017-01-23 21:38:36
【问题描述】:
我有一个包含多个模块和一个公共父模块的 Maven 项目。在这个项目中,有一些单元测试使用 Junit 和 surefire 一起运行,以及 BDD Cucumber 集成测试。我想运行两个单独的作业,一个运行所有单元测试,一个运行 BDD/集成测试。为此,我使用 Junit 类别注释对我的 BDD 运行器类进行了注释,如下所示:
@RunWith(Cucumber.class)
@CucumberOptions(
tags = { "@ATagToBeRun", "~@ATagNotToBeRun","~@ToBeImplemented" },
dryRun = false, strict = true,
features = "src/test/resources/cucumber/testing",
glue = { "com.some.company.test",
"com.some.company.another.test"})
@Category(value = IntegrationTest.class)
public class FlowExecutionPojoTest {
}
我在父 pom 中创建了一个 Maven 配置文件,它使用了旨在基于组过滤测试的 maven-surefire-plugin 功能。这是我的 Maven 配置:
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-spring</artifactId>
<version>1.2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<profile>
<id>testJewels</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<modules>
<module>../my-module</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<groups>com.some.company.IntegrationTest</groups>
</configuration>
</plugin>
</plugins>
</build>
</profile>
我的预期是,当我运行mvn test -PtestJewels 时,应该执行使用<groups> 标记中包含的类别注释的类。实际上没有执行任何带注释的类。
需要注意的一个有趣点是,当我使用 maven-surefire-plugin 2.18 版时,它可以工作,但从 2.18.1 版开始并没有。根据页面底部的documentation,版本 2.18.1 中关于被继承的类别发生了变化,但在我的情况下,它们在
【问题讨论】:
-
你能分享你的 pom 依赖吗?是否包含 cucumber-java、cucumber-junit 包?
-
@eg04lt3r 确定,将其添加到问题中
标签: java junit cucumber maven-surefire-plugin