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 – running JUnit tests through TestNG

  1. Open the previously created Java project in Eclipse.
  2. Create a new file named simple-junit-test.xml and paste the following code to it:
    <suite name="Simple JUnit Suite">
      <test junit="true" name="Simple JUnit test">
        <classes>
          <class name="test.sample.junit.JunitSampleTest" />
        </classes>
      </test>
    </suite>

    The prreceding suite contains a simple test in it. The test includes the JunitSampleTest class for the test execution. TestNG is configured to execute the JUnit tests in the said class by setting the value of the attribute junit to true.

  3. Select the previously created XML configuration file and run it as a TestNG test suite. You will see the following test result on the Eclipse Console window:

What ...

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