Transferred from: http://blog.csdn.net/a542551042/article/details/46729585
TestNG is a Java unit Test framework, very powerful, very convenient, but automatically generated test reports to improve, you can use the TestNG bring the Testng_xslt change TestNG report style, here is mainly about reportng, beautify TestNG report
TestNg (TestNg official website):
Http://testng.org/doc/index.html
Reportng (reportng official website):
http://reportng.uncommons.org/
Maventestng (Configure testng under Maven):
Http://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html
mavenreportng (configuring reportng under MAVEN requires FQ):
https://solidsoft.wordpress.com/2011/01/23/better-looking-html-test-reports-for-testng-with-reportng-maven-guide/
Reportng officially provides the ability to use the Ant Build Project, you can also use Maven,gradle, which is the use of Maven
- First make sure that the MAVEN project has been built and that the TestNG class has been added, generating the Testng.xml,pom.xml
- Create a Res folder under the project to store our testng.xml files in a single place, so that you can run different testng.xml (using Maven to run, you only need to change the pom.xml to refer to different testng.xml)
The structure is as follows:
Modify Maven's Pom file as follows:
<Projectxmlns= "http://maven.apache.org/POM/4.0.0"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupId>Maventestng</groupId> <Artifactid>Maventestng</Artifactid> <version>0.0.1-snapshot</version> <!--maven Run test name - <name>Report_test</name> <URL>http://maven.apache.org</URL> <!--maven references remote libraries - <repositories> <Repository> <ID>Java-net</ID> <URL>Http://download.java.net/maven/2</URL> </Repository> </repositories> <!--maven parameter configuration, which refers to different testng.xml - <Properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <XMLfileName>Testng.xml</XMLfileName> </Properties> <!--maven references are dependent on different jars - <Dependencies> <!--Dependent testng - <Dependency> <groupId>Org.testng</groupId> <Artifactid>Testng</Artifactid> <version>6.8.8</version> <Scope>Test</Scope> </Dependency> <!--Dependent reportng Association testng - <Dependency> <groupId>Org.uncommons</groupId> <Artifactid>Reportng</Artifactid> <version>1.1.4</version> <Scope>Test</Scope> <Exclusions> <exclusion> <groupId>Org.testng</groupId> <Artifactid>Testng</Artifactid> </exclusion> </Exclusions> </Dependency> <!--Dependent Guice - <Dependency> <groupId>Com.google.inject</groupId> <Artifactid>Guice</Artifactid> <version>3.0</version> <Scope>Test</Scope> </Dependency> </Dependencies> <Build> <Plugins> <!--Add plug-in association Testng.xml - <plugin> <groupId>Org.apache.maven.plugins</groupId> <Artifactid>Maven-surefire-plugin</Artifactid> <version>2.17</version> <Configuration> <Suitexmlfiles> <Suitexmlfile>Res/${xmlfilename}</Suitexmlfile> </Suitexmlfiles> </Configuration> </plugin> <!--Add plugins, add reportng listeners, modify the final testng report - <plugin> <groupId>Org.apache.maven.plugins</groupId> <Artifactid>Maven-surefire-plugin</Artifactid> <version>2.5</version> <Configuration> <Properties> < Property> <name>Usedefaultlisteners</name> <value>False</value> </ Property> < Property> <name>Listener</name> <value>Org.uncommons.reportng.HTMLReporter, Org.uncommons.reportng.JUnitXMLReporter</value> </ Property> </Properties> <WorkingDirectory>target/</WorkingDirectory> <Forkmode>Always</Forkmode> </Configuration> </plugin> </Plugins></Build></Project>
So basically, after modifying the Pom file, you will see that the jar is already dependent on completion
Testng.xml no need to modify
- Then right-click to run Pom.xml, select Maven test
- After viewing the console
- After running with the Maven plugin, the test report is viewed in target, and the index.html under HTML is the report generated by reportng.
This can be done, in addition to reportng, can beautify the testng report, there are testng_xslt
Mac eclipse+maven+testng+reportng Generating test reports