既然可以配置maven surefire在一个版本中执行jUnit测试和testNG测试。我不会详细说明为什么我这么做(ok,提示:testNG是我们的标准框架,但是像jnario这样的框架需要jUnit)。如何让maven surefire正确执行JUnit和TestNG测试?
一般的方式做到这一点是配置万无一失插件这样的:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>${surefire.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>${surefire.version}</version>
</dependency>
</dependencies>
</plugin>
这工作得很好,JUnit测试和TestNG测试得到执行。
但是 - 现在我看到testNG也尝试执行jUnit测试(可能反之亦然) - 当然没有成功,因为它不会看到它的任何注释,但它看起来像它重新将测试标记为“通过”...无论如何,除非我评论第二个依赖关系条目,否则某些报告工具不会在jUnit测试中显示测试失败。
有没有更好的方法来配置surefire,以便两个框架的测试只能由他们的测试运行者执行?
交叉发布在Maven-Users-List上:http://maven.40175.n5.nabble。com/maven-surefire-selecting-providers-td5764817.html –