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 regular expressions for dependency

  1. Create a new class named RegularExpressionXmlTest under the test.depends.xml package and replace the following code in it:
    package test.depends.xml;
    
    import org.testng.annotations.Test;
    
    public class RegularExpressionXmlTest {
      @Test(groups={"test"})
      public void regularExpMethod(){
        System.out.println("Dependent method");
      }
      
      @Test(groups={"starts-with-one"})
      public void startsWithMethodOne(){
        System.out.println("Starts with method one");
      }
      
      @Test(groups={"starts-with-two"})
      public void startsWithMethodTwo(){
        System.out.println("Starts with method two");
      }  
    }

    The preceding test class contains three test methods which print a message onto the console when executed. Each of the test methods belongs ...

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