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

  1. Create a new class named InheritedTest under the test.depends.method package and replace the following code in it:
    package test.depends.method;
    
    import org.testng.annotations.Test;
    
    public class InheritedTest extends SimpleDependencyTest{
      @Test(dependsOnMethods={"testOne"})
      public void testThree(){
        System.out.println("Test three method in Inherited test");
      }
      
      @Test
      public void testFour(){
        System.out.println("Test four method in Inherited test");
      }
    }

    The preceding test class contains two test methods which print a message name onto the console when executed. Here test method testThree depends on test method testOne. This is configured by using the attribute dependsOnMethods while 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