3-testng. xml
There are multiple methods to call testng:
- UseTestng. xmlFile
- Use ant
- Use command line
This section describesTestng. xml(You will find relevant documents about Ant and command line below ).
CurrentlyTestng. xmlThe DTD you use can be found on the home page: http://testng.org/testng-1.0.dtd (for more convenience, you can browse the HTML Version ).
Below isTestng. xmlFile example:
<!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 also specify a package name to replace 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, testngAllAnd only the classes containing testng annotations are retained.
You can also specify the groups and methods to include and exclude:
<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 alsoTestng. xml defines a new group and specifies additional details in the attributes, such as whether to run in parallel, how many threads are used, and whether the JUnit test is running ...... Refer to the DTD to obtain a complete list of functions, or continue to read this article.