[英]How to run multiple test classes or test methods using Maven?
In order to run all Maven tests, we can use:为了运行所有 Maven 测试,我们可以使用:
mvn clean test
If we want to run specific test class, we can use:如果我们想运行特定的测试类,我们可以使用:
mvn clean test -Dtest=className
If we want to run specific method from specific test class, we can use:如果我们想从特定的测试类运行特定的方法,我们可以使用:
mvn clean test -Dtest=className#methodName
But I want to run:但我想跑:
src\\test\\java
)src\\test\\java
)src\\test\\java
)src\\test\\java
的特定测试类的所有测试方法) Are there Maven commands using which I can achieve above two?是否有 Maven 命令使用我可以实现以上两个?
You can use wildcards - note that you have to quote the test argument so the shell does not expand the wildcard.您可以使用通配符 - 请注意,您必须引用 test 参数,以便 shell 不会扩展通配符。
mvn -Dtest="TestSquare,TestCi*le" test
(using maven-surefire-plugin:2.17) (使用 maven-surefire-plugin:2.17)
如果您想从子目录启动所有测试类,例如:/doc/ 您可以使用命令:
mvn -Dtest=*/doc/* test
You can add multiple classes in TestNG with their groups, like您可以在 TestNG 中添加多个类及其组,例如
<groups>
<run>
<include name = "checkintest" />
<include name = "videoSpider" />
<include name = "xmlTCUploader" />
<include name = "PALLogin" />
</run>
</groups>
<classes>
<class name="SeleniumUC"/>
<class name="PALTestCasesSuite"/>
</classes>
After this, you can use these group with Maven like -在此之后,您可以将这些组与 Maven 一起使用,例如 -
mvn -Dgroups=PALLogin test
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.