## TestNG Maven plug-ins

#### Table of Contents

### Maven 2

Maven 2 supports TestNG out of the box without the need to download any additional plugins (other than TestNG itself). It is recommended that you use version 2.4 or above of the Surefire plugin (this is the case in all recent versions of Maven).

You can find the full instructions on the Maven Surefire Plugin web site. There are also TestNG-specific instructions.

#### Specifying your pom.xml

The dependency in your project should look like the following:

     <dependency>
       <groupId>org.testng</groupId>
       <artifactId>testng</artifactId>
       <version>6.8</version>
       <scope>test</scope>
     </dependency>

#### Sample Report

A sample surefire report with TestNG can be found here.

### Maven TestNG Archetype (Martin Gilday)

Martin Gilday has added a new archetype for Maven2: to create a project using the archetype you simply have to specify my repository and the archetype ID.

      mvn archetype:create -DgroupId=org.martingilday -DartifactId=test1 -DarchetypeGroupId=org.martingilday -DarchetypeArtifactId=testng-archetype
        -DarchetypeVersion=1.0-SNAPSHOT -DremoteRepositories=http://www.martingilday.org/repository/

Of course substitute in your own groupId and artifactId.

Don't forget to keep checking back at Martin's blog for more updates.

### Maven 1 (by Andrew Glover)

The TestNG Maven plug-in is quite simple and consists of two goals and a series of optional properties.

Currently the 1.1 version of the plug-in is bundled with official releases of TestNG. To utilize the plug-in, copy the `maven-testng-plugin-.jar` to the `$MAVEN_HOME/plugins` directory.

For the latest version of the plug-in (1.2 as of 12/12/05), update your `maven.repo.remote` to include `http://www.vanwardtechnologies.com/repository/` and then issue the following command: `maven plugin:download`. Maven will issue a series of questions, answer them as follows:

`artifactId:` | `maven-testng-plugin`
groupId: | `testng`
version: | `1.2`

#### Goals

Goal | Description
--- | ---
`testng` | Runs TestNG
`testng:junit-report` | Creates a JUnit style report

#### Properties

Property | Optional? | Description
--- | --- | ---
`maven.testng.suitexml.name` | Yes | XML file name- defaults to `testng.xml`
`maven.testng.suitexml.dir` | Yes | Directory where XML file lives. Defaults to `${basedir}/test/conf`
`maven.testng.output.dir` | Yes | Default report directory. Defaults to `${maven.build.dir}/testng-output`
`maven.testng.report.dir` | Yes | Directory for JUnit reports. Defaults to `${maven.build.dir}/testngJunitReport`