ReportNG和Maven站点:需要帮助在Maven站点中生成ReportNG输出

时间:2014-07-14 23:05:40

标签: maven-3 testng maven-site-plugin reportng

目前我正在尝试将我的ReportNG报告生成在"网站"在项目报告部分。

创建ReportNG文件夹,并在我的计算机上的目录中生成带有该文件的index.html,并运行测试并输出正确的结果。

我只想在“项目报告”部分下创建ReportNG报告。

作为参考,我上周刚开始使用Maven作为我工作的一部分。

请告诉我我可以做些什么来解决这个问题,无论是获取新插件,还是新依赖项或我需要编辑的内容。

此外,如果您知道有任何理解Maven的资源,我将非常感激。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.Test.app</groupId>
<artifactId>mavenTestNG</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>

<dependencies>
    <!-- tag::joda[] -->
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.2</version>
    </dependency>
    <!-- end::joda[] -->
    <dependency>
    <groupId>org.uncommons</groupId>
    <artifactId>reportng</artifactId>
    <version>1.1.2</version>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
        </exclusion>
    </exclusions>
</dependency>
    <!-- tag::junit[] -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <!-- end::junit[] -->
    <!-- tag::spring[] -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.0.6.RELEASE</version>
    </dependency>
    <!-- end::spring[] -->
    <!-- tag::testng[] -->
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.8.7</version>
        <scope>test</scope>
    </dependency>
    <!-- end::testng[] -->
    <dependency>
        <groupId>com.google.inject</groupId>
        <artifactId>guice</artifactId>
        <version>3.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>velocity</groupId>
        <artifactId>velocity</artifactId>
        <version>1.4</version>
        <scope>test</scope>
    </dependency>
</dependencies>


<build>
    <plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
            <properties>
                <property>
                    <name>usedefaultlisteners</name>
                    <value>true</value>
                </property>
                <property>
                    <name>listener</name>
                    <value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter</value>
                </property>
            </properties>
            <workingDirectory>target/</workingDirectory>
        </configuration>
    </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.1</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <transformers>
                            <transformer
                                implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>com.Test.app.HelloWorld</mainClass>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
<reporting>   
<plugins>   
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>   
        <version>2.6</version>   
        <configuration>
            <properties>
                <property>
                    <name>usedefaultlisteners</name>
                    <value>true</value>
                </property>
                <property>
                    <name>listener</name>
                    <value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter</value>
                </property>
            </properties>
            <workingDirectory>target/</workingDirectory>
        </configuration>
    </plugin>   
</plugins>   


1 个答案:

答案 0 :(得分:0)

</plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <!-- You can specify a specific testng.xml file here <suiteXmlFiles> 
                    <suiteXmlFile>src/test/resources/testng-sample.xml</suiteXmlFile> </suiteXmlFiles> -->
                <!-- Or dynamically with something like '-DsuiteXmlFile=src/test/resources/testng-sample.xml' -->
                <suiteXmlFiles>
                    <suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
                </suiteXmlFiles>
                <!-- Build with '-DskipTests=true' to bypass test execution @ build 
                    time Default: false -->
                <skipTests>${skipTests}</skipTests>
                <testFailureIgnore>true</testFailureIgnore>
            </configuration>
        </plugin>