如何以HTML格式获取Maven报告?

时间:2014-11-14 16:07:27

标签: java maven

我有一个带有eclipse和一些硒测试的maven项目。 我可以在命令行中运行它们,我以txt和xml格式在目标文件夹中获取报告。

但我希望报告采用html格式。 我应该在POM文件中添加什么。

非常感谢。

这是我的POM.xml

....
<dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.44.0</version>
</dependency>
<dependency>
    <groupId>com.itextpdf</groupId>
    <artifactId>itextpdf</artifactId>
    <version>5.5.3</version>
</dependency>

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc6</artifactId>
    <version>11.2.0</version>
</dependency>

 <dependency>
     <groupId>javax.mail</groupId>
     <artifactId>mail</artifactId>
     <version>1.4.3</version>
    </dependency>

    </dependencies>



    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

        <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.4</version>
    <executions>
        <execution>
            <id>copy</id>
            <phase>package</phase>
        </execution>
    </executions>
</plugin>
        </plugins>
    </build>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

</project>

1 个答案:

答案 0 :(得分:2)

请参阅this question,正如第二个答案所指出的那样,您应该可以使用Maven Surefire Report plugin

“Surefire Report Plugin在$ {basedir} / target / surefire-reports下解析生成的TEST - *。xml文件,并使用DOXIA呈现它们,DOXIA创建测试结果的Web界面版本。”< / em>的

以下是配置它的XML:

<reporting>
 <plugins>

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-report-plugin</artifactId>
    <version>2.18</version>
  </plugin>

 </plugins>
</reporting>

以下任一命令都会调用它:

  • mvn site
  • mvn surefire-report:report