1<html>
2    <head>
3        <title>TestNG - Maven</title>
4
5        <link rel="stylesheet" href="testng.css" type="text/css" />
6        <link type="text/css" rel="stylesheet" href="http://beust.com/beust.css"  />
7        <script type="text/javascript" src="http://beust.com/prettify.js"></script>
8        <script type="text/javascript" src="banner.js"></script>
9
10        <script type="text/javascript" src="http://beust.com/scripts/shCore.js"></script>
11        <script type="text/javascript" src="http://beust.com/scripts/shBrushJava.js"></script>
12        <script type="text/javascript" src="http://beust.com/scripts/shBrushXml.js"></script>
13        <script type="text/javascript" src="http://beust.com/scripts/shBrushBash.js"></script>
14        <script type="text/javascript" src="http://beust.com/scripts/shBrushPlain.js"></script>
15        <link type="text/css" rel="stylesheet" href="http://beust.com/styles/shCore.css"/>
16        <link type="text/css" rel="stylesheet" href="http://beust.com/styles/shThemeCedric.css"/>
17        <script type="text/javascript">
18          SyntaxHighlighter.config.clipboardSwf = 'scripts/clipboard.swf';
19          SyntaxHighlighter.defaults['gutter'] = false;
20          SyntaxHighlighter.all();
21        </script>
22
23</head>
24
25<body onLoad="prettyPrint()">
26
27<script type="text/javascript">
28    displayMenu("maven.html")
29</script>
30
31
32<style type="text/css">
33    *.P1 { font-family:Sans; font-size:10pt; margin-left:0in; margin-right:0in; text-align:left ! important; text-indent:0inch; color:#a52a2a; }
34    *.P2 { font-family:Sans; font-size:10pt; margin-left:0in; margin-right:0in; text-align:left ! important; text-indent:0inch; }
35    *.P3 { font-family:'Nimbus Roman No9 L'; font-size:12pt; margin-left:0in; margin-right:0in; text-align:left ! important; text-indent:0inch; }
36    *.Standard { font-family:'Nimbus Roman No9 L'; font-size:12pt; }
37    *.Textbody { font-family:'Nimbus Roman No9 L'; font-size:12pt; margin-top:0in; margin-bottom:0.0835in; }
38    *.T1 { font-weight:bold; }
39    *.T2 { color:#353535; }
40    *.T3 { color:#a52a2a; font-weight:bold; }
41    *.T4 { color:#a52a2a; }
42    *.T5 { color:#353535; font-family:Sans; font-size:10pt; }
43    *.T6 { color:#a52a2a; font-family:Sans; font-size:10pt; font-weight:bold; }
44    *.T7 { color:#a52a2a; font-family:Sans; font-size:10pt; }
45  p,pre { width: 80%; }
46
47  ul.toc {
48    list-style: none;
49    margin:0 0.7em 0;
50    padding:0;
51    font-family: verdana, arial, sans-serif;
52  }
53  ul.toc li {
54    padding:0;
55    margin: 0.2em 0 0;
56  }
57  ul ul {
58    margin:0 2em 0;
59    padding: 0;
60    list-style-type: none;
61  }
62  li a {
63    display: block;
64    text-decoration: none;
65    padding: 2px 10px;
66    width: 140px;
67  }
68  ul.sub li a {
69    display: block;
70    border-top: none;
71    padding: 2px 10px;
72    background-color: transparent;
73  }
74</style>
75
76<h2>TestNG Maven plug-ins</h2>
77
78<h4>Table of Contents</h4>
79<ul class="toc">
80  <li class="first">
81    <a class="summary" href="#maven2">Maven2 Plugin</a>
82
83    <ul class="sub">
84      <li><a href="#archetype">Archetype</a></li>
85    </ul>
86  </li>
87
88  <li class="last"><a class="summary" href="#maven1">Maven 1 Plugin</a></li>
89</ul>
90
91<!--  begin maven2  -->
92<h3 id="maven2">Maven 2</h3>
93
94<p>Maven 2 supports TestNG out of the box without the need to download any additional plugins <em>(other than TestNG itself)</em>. 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).</p>
95
96<p>
97You can find the full instructions on the <a href="http://maven.apache.org/plugins/maven-surefire-plugin/">Maven Surefire Plugin web site</a>. There are also <a href="http://maven.apache.org/plugins/maven-surefire-plugin/examples/testng.html">TestNG-specific instructions</a>.
98</p>
99
100<h4>Specifying your pom.xml</h4>
101
102The dependency in your project should look like the following:
103
104<pre class="brush: xml">
105 &lt;dependency&gt;
106   &lt;groupId&gt;org.testng&lt;/groupId&gt;
107   &lt;artifactId&gt;testng&lt;/artifactId&gt;
108   &lt;version&gt;6.8&lt;/version&gt;
109   &lt;scope&gt;test&lt;/scope&gt;
110 &lt;/dependency&gt;
111</pre>
112
113<h4>Sample Report</h4>
114<p>
115A sample surefire report with TestNG can be found <a href="samplereport/index.html">here</a>.
116</p>
117<br/>
118<!--  end maven2  -->
119
120<!-- maven2 archetype -->
121<h3 id="archetype">Maven TestNG Archetype <em>(Martin Gilday)</em></h3>
122<p>
123  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.
124</p>
125  <pre class="brush: text">
126  mvn archetype:create -DgroupId=org.martingilday -DartifactId=test1 -DarchetypeGroupId=org.martingilday -DarchetypeArtifactId=testng-archetype
127    -DarchetypeVersion=1.0-SNAPSHOT -DremoteRepositories=http://www.martingilday.org/repository/</pre>
128
129<p>Of course substitute in your own groupId and artifactId.</p>
130<p>Don't forget to keep checking back at <a href="http://www.martingilday.org/updates/Maven+TestNG+Archetype">Martin's blog</a> for more updates. </p>
131<!-- end maven2 archetype -->
132
133<br/><br/>
134<h3 id="maven1">Maven 1 (by Andrew Glover)</h3>
135
136<p>The TestNG Maven plug-in is quite simple and consists of
137two goals and a series of optional properties.</p>
138
139<p>Currently the 1.1 version of the plug-in is bundled with
140official releases of TestNG. To utilize the plug-in, copy the
141<tt>maven-testng-plugin-<version>.jar</tt> to the <tt>$MAVEN_HOME/plugins</tt>
142directory.</p>
143
144<p>For the latest version of the plug-in (1.2 as of 12/12/05),
145update your <tt>maven.repo.remote</tt> to include <tt>http://www.vanwardtechnologies.com/repository/</tt>
146and then issue the following command: <tt>maven plugin:download</tt>. Maven will issue a series of questions,
147answer them as follows: <BR>
148<BR>
149<TABLE border="1" id="table1">
150    <TR>
151        <TD><tt>artifactId:</tt></TD>
152        <TD><tt>maven-testng-plugin</tt></TD>
153    </TR>
154    <TR>
155        <TD>groupId:</TD>
156        <TD><tt>testng</tt></TD>
157    </TR>
158    <TR>
159        <TD>version:</TD>
160        <TD><tt>1.2</tt></TD>
161    </TR>
162</TABLE>
163</p>
164
165
166<h4>Goals</h4>
167<table border="1" id="table2">
168    <tr>
169        <th>Goal</th>
170        <th>Description</th>
171    </tr>
172    <tr>
173        <td><tt>testng</tt></td>
174        <td>Runs TestNG</td>
175    </tr>
176    <tr>
177        <td><tt>testng:junit-report</tt></td>
178        <td>Creates a JUnit style report</td>
179    </tr>
180</table>
181<h4>Properties</h4>
182<table border="1" id="table3">
183    <tr>
184        <th>Property</th>
185        <th>Optional?</th>
186        <th>Description</th>
187    </tr>
188    <tr>
189        <td><tt>maven.testng.suitexml.name</tt></td>
190        <td>Yes</td>
191        <td>XML file name- defaults to <tt>testng.xml</tt></td>
192    </tr>
193    <tr>
194        <td><tt>maven.testng.suitexml.dir</tt></td>
195        <td>Yes</td>
196        <td>Directory where XML file lives. Defaults to <tt>${basedir}/test/conf</tt></td>
197    </tr>
198    <tr>
199        <td><tt>maven.testng.output.dir</tt></td>
200        <td>Yes</td>
201        <td>Default report directory. Defaults to <tt>${maven.build.dir}/testng-output</tt></td>
202    </tr>
203    <tr>
204        <td><tt>maven.testng.report.dir</tt></td>
205        <td>Yes</td>
206        <td>Directory for JUnit reports. Defaults to <tt>${maven.build.dir}/testngJunitReport</tt></td>
207    </tr>
208</table>
209
210<!-- end maven stuff -->
211
212<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
213<script type="text/javascript">
214_uacct = "UA-238215-2";
215urchinTracker();
216</script>
217
218</body>
219