【发布时间】:2021-04-29 10:54:01
【问题描述】:
JUNIT5 中将添加哪些属性来自动运行测试? 我该如何配置?
【问题讨论】:
标签: java spring-boot maven junit
JUNIT5 中将添加哪些属性来自动运行测试? 我该如何配置?
【问题讨论】:
标签: java spring-boot maven junit
您应该使用maven-surefire-plugin,例如:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Xmx1024M ${additional.test.jvm.args}</argLine>
<excludes>
<exclude>**/*ManagedTest.java</exclude>
</excludes>
<runOrder>alphabetical</runOrder>
</configuration>
</plugin>
</plugins>
</build>
如果您运行mvn test,您的代码将被编译并运行测试。
【讨论】:
你可以使用 maven 插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
<excludes>
<exclude>**/integration/*ITTest.java</exclude>
</excludes>
</configuration>
</plugin>
欲了解更多信息,请参阅doc
【讨论】: