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 – converting a JUnit test to a TestNG test

  1. Select the previously created Java project.
  2. Now create a new class file named JunitToTestngTest under the package test.sample.testng and add the following code to it:
    package test.sample.testng; import org.testng.annotations.AfterClass; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; public class JunitToTestngTest { @BeforeClass public static void beforeClassMethod(){ System.out.println("Junit before class method"); } @BeforeMethod public void beforeMethod(){ System.out.println("Junit before method"); } @Test public void testMethod(){ System.out.println("Junit test method"); ...

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