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 classes

Perform the following steps to create a test with classes:

  1. Open the sample project that we created earlier.
  2. Add new file TestNG configuration XML by name class-testng.xml to the project with following content.
    <suite name="Class Suite" verbose="1">
      <test name="Test">
        <classes>
          <class name="test.firstpackage.FirstTestClass" />
          <class name="test.secondpackage.FirstTestClass" />
          <class name="test.thirdpackage.FirstTestClass" />
        </classes>
      </test>
    </suite>

    The preceding testng XML suite defines a test with three classes (one from each package). To add a class to your test suite just use a combination of classes and class tag as shown. Use the class tag with the attribute name having a value of the class name ...

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