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 – using test annotation on class

  1. Open Eclipse and create a sample Java project as shown in the following screenshot with TestNG library added to its build path:
    Time for action – using test annotation on class
  2. Add a new test class with the name TestClass under the test package and add the following code to it:
    package test;
    
    import org.testng.annotations.Test;
    
    @Test
    public class TestClass {
    
      public void testMethodOne(){
        System.out.println("Test method one.");
      }
    
      public void testMethodTwo(){
        System.out.println("Test method two.");
      }
    
      private void testMethodThree(){
        System.out.println("Test method three.");
      }
    }

    The preceding class contains three methods out of which two are public methods ...

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