TestNG Makes Java Unit Testing a Breeze
By Filippo Diotalevi2005-03-22
Defining test groups
@Test(groups = {"tests.string"})
In this particular case, you declare that the annotated method belongs to the tests.string group. Because the parameter groups is an array, it is possible to specify multiple groups, separating their names with commas. For example, in the sample application, you can create different tests for Strings, numbers, and booleans, and then run them selectively, configuring TestNG as illustrated in Listing 4.
Listing 4. Configuration file with different groups
<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
<suite name="My suite">
<test name="Simple example">
<groups>
<run>
<include name="tests.string" />
<include name="tests.math" />
<exclude name="tests.boolean"/>
</run>
</groups>
<classes>
.... list classes here....
</classes>
</test>
</suite>
Obviously, when you run different groups of tests, the HTML report can show all the tests in a single list, as well as in separate lists for each group, making it possible to immediately understand the source of any problem.
Tutorial pages:
|
First Published on IBM DeveloperWorks
|
|||||||||
You might also want to check these out:
|
Leave a Comment on "TestNG Makes Java Unit Testing a Breeze"
You must be logged in to post a comment.
Link to This Tutorial Page!

