TestNG the official document of the Chinese translation of the 3rd chapter, see the original http://testng.org/doc/documentation-main.html
3-testng.xml
There are several different ways to invoke testng:
* Use Testng.xml file
* Use Ant
* from the command line
This section describes the format of the Testng.xml (the file will be followed by Ant and the command line).
The current Testng.xml DTD file can be found from the official: Http://testng.org/testng-1.0.dtd. (For ease of use, you might prefer to browse HTML versions).
Here is an example of the Testng.xml file:
<!DOCTYPE suite SYSTEM "http://testng.org/testng- 1.0.dtd" >
<suite name="Suite1" verbose="1" >
<test name="Nopackage" >
<classes>
<class name="NoPackageTest" />
</classes>
</test>
<test name="Regression1" >
<classes>
<class name="test.sample.ParameterSample" />
<class name="test.sample.ParameterTest" />
</classes>
</test>
</suite>
You can specify the package name instead of the class name:
<!DOCTYPE suite SYSTEM "http://testng.org/testng- 1.0.dtd" >
<suite name="Suite1" verbose="1" >
<test name="Regression1" >
<packages>
<package name="test.sample" />
</packages>
</test>
</suite>
In this example, TestNG will find all the classes in the package test.sample and keep only the classes with testng annotation.
You can also specify groups and methods that are included or not included:
<test name="Regression1">
<groups>
<run>
<exclude name="brokenTests" />
<include name="checkinTests" />
</run>
</groups>
<classes>
<class name="test.IndividualMethodsTest">
<methods>
<include name="testMethod" />
</methods>
</class>
</classes>
</test>
You can also define new groups in Testng.xml, specifying additional details about properties, such as whether to run tests in parallel, how many threads to use, whether to run JUnit tests, and so on ...
Check the DTD file for a complete list of attributes.