reportng在maven中的配置


reportng是替代testng報告的一個報告插件,優勢在於美觀。不過1.1.4版本是reportng的最后一個版本,已經不再更新了。

對比下兩者的不同,下面是testng自帶的報告,打開就很慢:

下面是reportng的報告,看着是不是更容易接收?

在maven項目中配置reportng,需要做幾處修改:

(1)pom.xml 添加依賴

    <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>
        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>4.0</version>
            <scope>test</scope>
        </dependency>        

然后,添加插件

<build>
        <plugins>
        <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.17</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>xmlfile/testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</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>
                </configuration>
            </plugin>
        </plugins>
    </build>

(2)testng.xml中配置listener:

     <listeners>
    
        <listener class-name="org.uncommons.reportng.HTMLReporter" />
                <listener class-name="org.uncommons.reportng.JUnitXMLReporter" />
    </listeners>

配置完成后,運行testng,在\test-output\html點擊index.html,得到結果報告。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM