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

  1. Create a new package named regularexp under the existing package test.depends in the earlier project.
  2. Create a new class named RegularExpressionTest under the test.depends.regularexp package and replace the following code in it:
    package test.depends.regularexp;
    
    import org.testng.annotations.Test;
    
    public class RegularExpressionTest {
      @Test(dependsOnGroups={"starts-with.*"})
      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 ...

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