Tuesday, 27 November 2012

Grouping Tests - TestNG

One of the many brilliant TestNG features is the ability to group tests.

This is a high-level overview of how I structure this; I will try and flesh this out when I get some down time.

From command line, invoke TestNG
java org.testng.TestNg FullRegression.xml
(from memory) (note, classpaths will probably need to be set up)

My file, FullRegression.xml just references other files.


<suite name="MyProjectTestSuite" verbose="3" >
 <suite-files>
  <suite-file path="./Regression_Story101.xml" />
  <suite-file path="./Regression_Story102.xml" />
  <suite-file path="./Regression_Story103.xml" />
  <suite-file path="./Regression_Story104.xml" />
  <suite-file path="./Regression_Story105.xml" />
  <suite-file path="./Regression_Story106.xml" />
  <suite-file path="./Regression_Story107.xml" />
  <suite-file path="./Regression_Other.xml" />
  <suite-file path="./Regression_Failing.xml" />
 </suite-files>
</suite>


Example of a subsequent file looks something like this


<suite name="Story104" verbose="3" >
 <test name="Regression1">
  <groups>
   <run>  
    <exclude name="overkill" />
    <exclude name="failing" />
<include name="story104" />
   </run>
  </groups>
  <packages>
   <package name="com.whiteboxit.mattTestA.tests" />
  </packages>
 </test>
</suite>

Why have I done this

Well, visibility. My auto-generated html run results are now broken down by story. This looks awesome. And it is really easy for me to keep on top of something which has started failing, or whatever.

3 comments:

  1. Blogspot 'interpreted' my xml...The power of proof-reading. Anyway, fixed now.

    ReplyDelete
  2. Ant sent me here! Also TestNG FTW! Woot!

    ReplyDelete
  3. I can test too:

    Example of a subsequent file looks something like this








    *End*

    ReplyDelete

Robot Framework, Basic Setup

Plug: Robot Framework is quick to setup, easy to write tests for, and super fast to triage failures in. The last point really sets it apart...