1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
|
<html>
<head>
<title>TestNG - Maven</title>
<link rel="stylesheet" href="testng.css" type="text/css" />
<link type="text/css" rel="stylesheet" href="http://beust.com/beust.css" />
<script type="text/javascript" src="http://beust.com/prettify.js"></script>
<script type="text/javascript" src="banner.js"></script>
<script type="text/javascript" src="http://beust.com/scripts/shCore.js"></script>
<script type="text/javascript" src="http://beust.com/scripts/shBrushJava.js"></script>
<script type="text/javascript" src="http://beust.com/scripts/shBrushXml.js"></script>
<script type="text/javascript" src="http://beust.com/scripts/shBrushBash.js"></script>
<script type="text/javascript" src="http://beust.com/scripts/shBrushPlain.js"></script>
<link type="text/css" rel="stylesheet" href="http://beust.com/styles/shCore.css"/>
<link type="text/css" rel="stylesheet" href="http://beust.com/styles/shThemeCedric.css"/>
<script type="text/javascript">
SyntaxHighlighter.config.clipboardSwf = 'scripts/clipboard.swf';
SyntaxHighlighter.defaults['gutter'] = false;
SyntaxHighlighter.all();
</script>
</head>
<body onLoad="prettyPrint()">
<script type="text/javascript">
displayMenu("maven.html")
</script>
<style type="text/css">
*.P1 { font-family:Sans; font-size:10pt; margin-left:0in; margin-right:0in; text-align:left ! important; text-indent:0inch; color:#a52a2a; }
*.P2 { font-family:Sans; font-size:10pt; margin-left:0in; margin-right:0in; text-align:left ! important; text-indent:0inch; }
*.P3 { font-family:'Nimbus Roman No9 L'; font-size:12pt; margin-left:0in; margin-right:0in; text-align:left ! important; text-indent:0inch; }
*.Standard { font-family:'Nimbus Roman No9 L'; font-size:12pt; }
*.Textbody { font-family:'Nimbus Roman No9 L'; font-size:12pt; margin-top:0in; margin-bottom:0.0835in; }
*.T1 { font-weight:bold; }
*.T2 { color:#353535; }
*.T3 { color:#a52a2a; font-weight:bold; }
*.T4 { color:#a52a2a; }
*.T5 { color:#353535; font-family:Sans; font-size:10pt; }
*.T6 { color:#a52a2a; font-family:Sans; font-size:10pt; font-weight:bold; }
*.T7 { color:#a52a2a; font-family:Sans; font-size:10pt; }
p,pre { width: 80%; }
ul.toc {
list-style: none;
margin:0 0.7em 0;
padding:0;
font-family: verdana, arial, sans-serif;
}
ul.toc li {
padding:0;
margin: 0.2em 0 0;
}
ul ul {
margin:0 2em 0;
padding: 0;
list-style-type: none;
}
li a {
display: block;
text-decoration: none;
padding: 2px 10px;
width: 140px;
}
ul.sub li a {
display: block;
border-top: none;
padding: 2px 10px;
background-color: transparent;
}
</style>
<h2>TestNG Maven plug-ins</h2>
<h4>Table of Contents</h4>
<ul class="toc">
<li class="first">
<a class="summary" href="#maven2">Maven2 Plugin</a>
<ul class="sub">
<li><a href="#archetype">Archetype</a></li>
</ul>
</li>
<li class="last"><a class="summary" href="#maven1">Maven 1 Plugin</a></li>
</ul>
<!--
TestNG has plug-ins for both Maven 1 and Maven 2.
-->
<!-- begin maven2 -->
<h3 id="maven2">Maven 2</h3>
<p>Maven2 should support TestNG out of the box without the need to download any additional plugins <em>(other than TestNG itself)</em>.
<h4>Snapshot Build Updates</h4>
<p>
The latest current good version of the Surefire plugin that you want is <b>2.4</b>. You can find the full instructions on the <a href="http://maven.apache.org/plugins/maven-surefire-plugin/">Surefire web site</a> (here are the <a href="http://maven.apache.org/plugins/maven-surefire-plugin/examples/testng.html">TestNG-specific instructions</a>).
<!--
</p>
<p>
To get the apache ibiblio snapshot repository added to your Maven project you will need to add a section like
the following to your <code>pom.xml</code>:
</p>
<pre class="prettyprint">
<pluginRepositories>
<pluginRepository>
<id>apache.snapshots</id>
<url>http://people.apache.org/repo/m2-snapshot-repository/</url>
</pluginRepository>
</pluginRepositories>
</pre>
<h4>Surefire Documentation</h4>
The TestNG Surefire documentation can be found on <a href="http://maven.apache.org/plugins/maven-surefire-plugin/testng.html">Apache's web site</a>.
<h4>Reference</h4>
<p>Though this section will include a lot more TestNG specific
features, the overall test plugin properties should be mostly covered on Maven's site.</p>
<h4>Overview</h4>
<p>Most of the configuration aspects with Maven will be centered around your pom.xml's <a href="http://maven.apache.org/maven-model/maven.html">build section</a>. In here you define things like build output directories,
location of test source code, as well as configure plugin
parameters, like those you will need to get TestNG setup the
way that you prefer. Following is a sample portion of this
section in a pom.xml file.</p>
<pre class="prettyprint">
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.5</version>
<scope>test</scope>
<classifier>jdk15</classifier>
</dependency>
<dependencies>
<build>
..
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4-SNAPSHOT</version>
<configuration>
<groups>functest,util</groups>
</configuration>
</plugin>
</plugins>
</build>
</pre>
<p>
The most notable section is the <tt>configuration</tt> element. Within the boundaries of this element you can define all of
the configurable TestNG properties.
</p>
-->
<h4>Configuration</h4><h5>Goals</h5><table border="1" id="table2">
<tr>
<th>Goal</th><th>Description</th></tr><tr>
<td><tt>test</tt></td><td>Compiles and runs your tests</td></tr><tr>
<td><tt>site</tt></td><td>Creates your Maven generated site, which will include the TestNG report output.</td></tr></table><h4>Properties</h4><table border="1" id="table3">
<tr>
<th>Property</th><th>Optional?</th><th>Description</th></tr><tr>
<td><tt>includes</tt></td><td>No</td><td>Comma delimited list of regexp patterns to include source files with. Ie **/Test*.java</td></tr><tr>
<td><tt>groups</tt></td><td>Yes</td><td>Comma delimited list of groups to be included in test. If left blank will run all tests by default.</td></tr><tr>
<td><tt>excludeGroups</tt></td><td>Yes</td><td>Comma delimited list of groups that should <em>not</em> be included in test run.</td></tr><tr>
<td><tt>suiteXmlFiles</tt></td><td>Yes</td><td>Comma delimited list of file paths pointing to testng.xml suite files. <tt>(src/test-data/testng-core.xml,src/test-data/testng-functional.xml)</tt>
<p><em>Warning: When defining suiteXmlFiles most of the other parameters are ignored.</em></p></td></tr><tr>
<td><tt>threadCount</tt></td><td>Yes</td><td>Number of threads to run for tests</td></tr><tr>
<td><tt>parallel</tt></td><td>Yes</td><td>When using threads, whether or not to run them in parallel. Use <em>tests</em> to have each test run in its own thread or
<em>methods</em> to have the methods invoked from different threads.</td></tr>
</table>
<h3>Java 1.4</h3>
<p>
In order to use javadoc style annotations you currently <em>must</em> run Maven with a java 1.4 jvm in order for them to be seen. If
you try running your javadoc annotated tests in a 1.5 jvm they will most likely not be found. It is hoped in a future release this problem
will be eliminated.
</p>
<h4>Sample Report</h4>
<p>
A sample surefire report with TestNG can be found <a href="samplereport/index.html">here</a>.
</p>
<br/>
<!-- end maven2 -->
<!-- maven2 archetype -->
<h3 id="archetype">Maven TestNG Archetype <em>(Martin Gilday)</em></h3>
<p>
Martin Gilday has added a new archetype for Maven2 users that should make it easier to get going with TestNG. You can find more about
this in his blog entry <a href="http://www.martingilday.org/updates/Maven+TestNG+Archetype">here</a>, but the basics for configuring it have been pasted below.
</p>
<p>
To create a project using the archetype you simply have to specify my repository and the archetype ID.
</p>
<pre class="brush: text">
mvn archetype:create -DgroupId=org.martingilday -DartifactId=test1 -DarchetypeGroupId=org.martingilday -DarchetypeArtifactId=testng-archetype
-DarchetypeVersion=1.0-SNAPSHOT -DremoteRepositories=http://www.martingilday.org/repository/</pre>
<p>Of course substitute in your own groupId and artifactId.</p>
<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>
<!-- end maven2 archetype -->
<br/><br/>
<h3 id="maven1">Maven 1 (by Andrew Glover)</h3>
<p>The TestNG Maven plug-in is quite simple and consists of
two goals and a series of optional properties.</p>
<p>Currently the 1.1 version of the plug-in is bundled with
official releases of TestNG. To utilize the plug-in, copy the
<tt>maven-testng-plugin-<version>.jar</tt> to the <tt>$MAVEN_HOME/plugins</tt>
directory.</p>
<p>For the latest version of the plug-in (1.2 as of 12/12/05),
update your <tt>maven.repo.remote</tt> to include <tt>http://www.vanwardtechnologies.com/repository/</tt>
and then issue the following command: <tt>maven plugin:download</tt>. Maven will issue a series of questions,
answer them as follows: <BR>
<BR>
<TABLE border="1" id="table1">
<TR>
<TD><tt>artifactId:</tt></TD>
<TD><tt>maven-testng-plugin</tt></TD>
</TR>
<TR>
<TD>groupId:</TD>
<TD><tt>testng</tt></TD>
</TR>
<TR>
<TD>version:</TD>
<TD><tt>1.2</tt></TD>
</TR>
</TABLE>
</p>
<h4>Goals</h4>
<table border="1" id="table2">
<tr>
<th>Goal</th>
<th>Description</th>
</tr>
<tr>
<td><tt>testng</tt></td>
<td>Runs TestNG</td>
</tr>
<tr>
<td><tt>testng:junit-report</tt></td>
<td>Creates a JUnit style report</td>
</tr>
</table>
<h4>Properties</h4>
<table border="1" id="table3">
<tr>
<th>Property</th>
<th>Optional?</th>
<th>Description</th>
</tr>
<tr>
<td><tt>maven.testng.suitexml.name</tt></td>
<td>Yes</td>
<td>XML file name- defaults to <tt>testng.xml</tt></td>
</tr>
<tr>
<td><tt>maven.testng.suitexml.dir</tt></td>
<td>Yes</td>
<td>Directory where XML file lives. Defaults to <tt>${basedir}/test/conf</tt></td>
</tr>
<tr>
<td><tt>maven.testng.output.dir</tt></td>
<td>Yes</td>
<td>Default report directory. Defaults to <tt>${maven.build.dir}/testng-output</tt></td>
</tr>
<tr>
<td><tt>maven.testng.source.dir</tt></td>
<td>Yes</td>
<td>For 1.4- where test source is. Defaults to <tt>${basedir}/test/java/</tt></td>
</tr>
<tr>
<td><tt>maven.testng.report.dir</tt></td>
<td>Yes</td>
<td>Directory for JUnit reports. Defaults to <tt>${maven.build.dir}/testngJunitReport</tt></td>
</tr>
</table>
<p>A sample JUnit sytle report generated via the TestNG maven
plug-in can be found <A
HREF="http://www.vanwardtechnologies.com/nfjs/testng/sample-report/junit-noframes.html#top">here</A>.
</p>
<!-- end maven stuff -->
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<script type="text/javascript">
_uacct = "UA-238215-2";
urchinTracker();
</script>
</body>
|