如何告诉Maven和TestNG运行特定的测试类和suite.xml文件?

如何告诉Maven和TestNG运行特定的测试类和suite.xml文件?

问题描述:

我希望能够使用maven从我的testng套件中运行特定的测试类.我的测试类取决于testngsuite.xml文件中的参数.我可以运行mvn test -DsuiteXmlFile=mysuite.xmlmvn test -Dtest=sometest.有什么办法可以将两者结合起来?

I want to be able to run a specific test class from my testng suite using maven. My test classes are dependent on parameters from the testngsuite.xml file. I can run mvn test -DsuiteXmlFile=mysuite.xml or mvn test -Dtest=sometest. Is there any way to combine these two?

此链接显示了如何执行另一个操作,但不能同时执行两个操作.

This link shows how to do one of the other but not both. How do I tell Maven and TestNG to run either a specific test class or a suite.xml file?

套件文件用于定义测试运行.

Suite files are used to define a test run.

这意味着如果只需要一个测试,只需编写一个专用的套件文件.

That means if you want only one test, just write a dedicated suite file.