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 test

Perform the following steps for using regular expressions for test:

  1. We will use the sample project created earlier for regular expressions.
  2. Add a new file TestNG configuration XML named regexp-testng.xml to the project with the following content:
    <suite name="Regular Exp Suite" verbose="1">
      <test name="Regular Exp Test">
        <classes>
          <class name="test.regularexppackage.RegularExpClass">
            <methods>
              <include name=".*Test.*" />
            </methods>
          </class>
        </classes>
      </test>
    </suite>

    The preceding testng XML suite is configured to consider only those test methods from a particular class whose name contains the word Test in it. The regular expression is considered by use of .* before and after the text.

  3. Now run the ...

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