Mac eclipse+maven+testng+reportng Generating test reports

Source: Internet
Author: User
Tags testng

Transferred from: http://blog.csdn.net/a542551042/article/details/46729585

  1. 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

    1. First make sure that the MAVEN project has been built and that the TestNG class has been added, generating the Testng.xml,pom.xml
    2. 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:

    3. 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
    4. Testng.xml no need to modify

    5. Then right-click to run Pom.xml, select Maven test
    6. After viewing the console
    7. 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.
  2. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.