O'Reilly logo

TestNg Beginner's Guide by Varun Menon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – creating a test with methods

Perform the following steps to create a test with methods:

  1. We will use the same sample project created earlier for defining a test suite.
  2. Add a new file TestNG configuration XML by name method-testng.xml to the project with following content:
    <suite name="Method Suite" verbose="1">
      <test name="Method Test">
        <classes>
          <class name="test.firstpackage.FirstTestClass">
            <methods>
              <include name="firstTest" />
            </methods>
          </class>
        </classes>
      </test>
    </suite>

    The preceding testng XML suite defines a class that needs to be considered for test execution and the test method that needs to be included for execution. To add methods to your test suite we have to use the tags methods and include/exclude under them to add ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required