|
MavenPlugin
Using the Maven plugin
TestNG XSLT Maven PluginTo get started with the Maven plugin you can have a look at the Maven test project that is bundled with the distribution zip (directory test/maven). The pom.xml file for this test project is also available here In order to get the plugin you need to configure the following repository: <pluginRepositories>
<pluginRepository>
<id>testng-xslt-plugin</id>
<url>http://www.cosminaru.ro/maven/</url>
</pluginRepository>
</pluginRepositories>Since the input of this plugin is a TestNG test run result, you need to also configure the Surefire plugin and the TestNG dependencies: <dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.11</version>
<scope>test</scope>
<classifier>jdk15</classifier>
</dependency>
</dependencies>
...
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</build>The TestNG XSLT Maven plugin is a report plugin that will run in the site generation phase of the build, so we will add it in the reporting section of the pom.xml file. <reporting>
<plugins>
<plugin>
<groupId>org.testng.xslt</groupId>
<artifactId>testng-xslt-plugin</artifactId>
<version>1.0.9</version>
</plugin>
</plugins>
</reporting>With all of these in place, you are good to go and should see the results in the "Project reports" section of the Maven project site. In order to pass parameters to the XSL transformation, you can do this easily by configuring the plugin using the same names as the XSL parameters without the "testNgXslt." prefix. Below is a sample on how to configure these parameres. <reporting>
<plugins>
<plugin>
<groupId>org.testng.xslt</groupId>
<artifactId>testng-xslt-plugin</artifactId>
<version>1.1</version>
<configuration>
<!--Setting the output directory (testNgXslt.outputDir)-->
<outputDir>${project.basedir}/target/site/${pom.artifactId}</outputDir>
<!--Setting the testNgXslt.showRuntimeTotals flag-->
<showRuntimeTotals>true</showRuntimeTotals>
<!--Setting the testNgXslt.cssFile parameter. This should be relative to the '${basedir}/target/site/testng-xslt' directory-->
<cssFile>myCustomStyle.css</cssFile>
</configuration>
</plugin>
</plugins>
</reporting>Since version 1.0.3, the plugin offers the possibility to set the location of Surefire output directory (thanks to Francis Henninger) in situations where Surefire writes to a non-default location. This is used to retrieve the actual path of the testng-results.xml file. This is achieved by setting the surefireReportDirectory parameter: <reporting>
<plugins>
<plugin>
...
<configuration>
<surefireReportDirectory>the/surefire/output/dir</surefireReportDirectory>
</configuration>
</plugin>
</plugins>
</reporting>
|
I am unable to download this from the repository. I do see it there!