------ Using Test NG ------ Brett Porter ------ 2 May 2006 ------ Using Test NG * Configuring Test NG To get started with Test NG, include the following dependency in your project: ----- ... org.testng testng 4.7 test jdk15 ... ----- <> if you are using JDK 1.4 Javadoc annotations for your Test NG tests, replace jdk15 with jdk14 above. This is the only step that is required to get started - you can now create tests in your test source directory (eg, <<>>, and as long as they are named using the defaults such as *Test.java they will be run by Surefire as Test NG tests. If you'd like to use a different naming scheme, you can change the <<>> parameter, as discussed in the {{{howto.html} How to Use}} page. * Using Suite XML Files Another alternative is to use test NG suite XML files. This allows flexbile configuration of the tests to be run. These files are created as normal, and then added to the Surefire plugin configuration: ----- ... org.apache.maven.plugins maven-surefire-plugin testng.xml ... ----- This configuration will override the includes and excludes patterns and run all tests in the suite files. * Using Groups Test NG allows you to group your tests. You can then execute a specific group or groups. To do this with Surefire, use the <<>> parameter, for example: ----- ... org.apache.maven.plugins maven-surefire-plugin functest,perftest ... ----- Likewise, the <<>> parameter can be used to run all but a certain set of groups. * Running tests in parallel Test NG allows you to run your tests in parallel, including JUnit tests. To do this, you must enable the <<>> parameter, and may change the <<>> parameter if the default of 5 is not sufficient. For example: ----- ... org.apache.maven.plugins maven-surefire-plugin true 10 ... ----- This is particularly useful for slow tests that can have high concurrency, or to quickly and roughly assess the independance and thread safety of your tests and code. For more information on Test NG, see the project {{{http://www.testng.org} web site}}.