English version of testng official documentation (03) -- testng. xml

Source: Internet
Author: User
Tags testng
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.

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.