gpt4 book ai didi

unit-testing - 如何使用 maven-surefire-plugin 在同一项目中执行 JUnit 和 TestNG 测试?

转载 作者:行者123 更新时间:2023-12-03 07:23:44 32 4
gpt4 key购买 nike

现在我有两种类型的测试,但是当我说“mvn test”时,它只执行 TestNG 测试而不执行 Junit。我想一个接一个地执行这两个操作。有什么想法吗?

最佳答案

官方方式 selecting providers .

You can also specify multiple providers as dependencies, and they will all be run and produce a common report. This may be especially handy with external providers, since there are few use-cases for combining the included providers.

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.18.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>2.18.1</version>
</dependency>
</dependencies>
</plugin>

有关此的更多信息:Mixing TestNG and JUnit tests in one Maven module – 2013 edition

此内容的当前链接位于 maven-surefire-plugin examples 。搜索“运行 TestNG 和 JUnit 测试”。

您需要配置 testng 提供程序以忽略 junit 测试,如下所示:

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<properties>
<property>
<name>junit</name>
<value>false</value>
</property>
</properties>
</configuration>
[...providers as dependecies, see above...]
</plugin>

关于unit-testing - 如何使用 maven-surefire-plugin 在同一项目中执行 JUnit 和 TestNG 测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1232853/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com