使用Maven,如何运行特定的测试? [英] Using Maven, how do I run specific tests?
本文介绍了使用Maven,如何运行特定的测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的项目中有数千个单元测试,我想选择一个或几个从命令行运行.这样做的命令是什么?
I have thousands of unit tests in my project, and I'd like to choose one or a couple of them to run from the command line. What's the command to do that?
推荐答案
通过将-Dtest=<class>
标志传递给Maven,可以在一个类中运行所有测试:
You can run all the tests in a class, by passing the -Dtest=<class>
flag to Maven:
mvn clean test -Dtest=xxxxTest
从Surefire 2.8开始,您还可以使用相同的标志运行单个测试,例如在单元测试中使用方法testA
:
Since Surefire 2.8, you can also run an individual test, say a method testA
within your unit tests, using the same flag:
mvn clean test -Dtest=xxxxTest#testA
More examples for running multiple tests, by name pattern or name lists, can be found in the Maven Surefire documentation > Running a Single Test.
这篇关于使用Maven,如何运行特定的测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文