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 that depends on a group

  1. Create a new package named groups under the test.depends package in the earlier project.
  2. Create a new class named SimpleGroupDependency under the test.depends.groups package and replace the following code in it:
    package test.depends.groups;
    
    import org.testng.annotations.Test;
    
    public class SimpleGroupDependency {
      @Test(dependsOnGroups={"test-group"})
      public void groupTestOne(){
        System.out.println("Group Test method one");
      }
      
      @Test(groups={"test-group"})
      public void groupTestTwo(){
        System.out.println("Group test method two");
      }
      
      @Test(groups={"test-group"})
      public void groupTestThree(){
        System.out.println("Group Test method three");
      }
    }

    The preceding test class contains three test methods which ...

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