TestNG Official Document Chinese version (3)-testng.xml

Source: Internet
Author: User
Tags list of attributes testng

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.