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 – including test methods

Perform the following steps to include test methods:

  1. Open the previously created Java project.
  2. Create a new class named IncludeExcludeMethodTest under the test.sample package and add the following code to it:
    package test.sample;
    
    import org.testng.annotations.Test;
    
    public class IncludeExcludeMethodTest {
      
      @Test
      public void testMethodOne(){
        System.out.println("Test method one.");
      }
      
      @Test
      public void testMethodTwo(){
        System.out.println("Test method two");
      }
      
      @Test
      public void testMethodThree(){
        System.out.println("Test method three");
      }
    
    }

    The preceding code contains a simple test class with three test methods. These test methods print a message onto the console when executed.

  3. Create another new class named IncludeExcludeMethodCode ...

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