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 multiple tests

  1. Create a new class named MultiDependencyTest under the test.depends.method package and replace the following code in it:
    package test.depends.method;
    
    import org.testng.annotations.Test;
    
    public class MultiDependencyTest {
      @Test(dependsOnMethods={"testTwo","testThree"})
      public void testOne(){
        System.out.println("Test method one");
      }
      
      @Test
      public void testTwo(){
        System.out.println("Test method two");
      }
      
      @Test
      public void testThree(){
        System.out.println("Test method three");
      }
    }

    The preceding test class contains three test methods which print a message name onto the console when executed. Here test method testOne depends on test methods testTwo and testThree. This is configured by using ...

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