Netbeans maven-surefire-plugin不生成HTML

时间:2011-11-07 17:05:51

标签: java junit maven-surefire-plugin

如何运行'mvn'。

我正在使用Netbeans 7,当我运行我的单元测试时,我确实从我的项目/目标文件夹中生成了XML文件

/target/surefire-reports/TEST-package.name.ClassNameTest.xml

/target/surefire-reports/TEST-package.name.ClassNameTest.txt

但是来自我的测试包中的所有xml和txt文件,

我无法弄清楚如何生成HTML报告。

我目前正在使用Maven Netbeans项目。这是我的pom.xml文件:

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

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.11.0</version>
    </dependency>  
</dependencies>
<groupId>com.honeycomb</groupId>
<artifactId>com.honeycomb</artifactId>

<!-- To use the report goals in your POM or parent POM -->  
<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.10</version>
            <configuration>
                <testFailureIgnore>true</testFailureIgnore>
            </configuration>
        </plugin>
    </plugins>
</reporting>

我可以让我的测试通过,我在Netbeans中使用带有Junit4的内置单元运行器。

我已经搜索了所有地方,我发现所有这些都是文档记录不充分的示例,而不是关于如何使用我的测试结果生成报告HTML文件的完整演练。

不确定这是否相关,但我是在Windows XP下开发的。 JDK 7.我使用的Maven直接来自Netbeans项目。

通过使用我已经看过帖子和示例:

http://maven.apache.org/maven-1.x/plugins/junit-report/goals.html

junit-report:报告和junit-report但我似乎无法弄清楚这些东西。

只需查找生成的简单HTML文件。

1 个答案:

答案 0 :(得分:1)

如果您运行命令mvn surefire-report:report,那么您应该会在surefire再次运行测试后找到名为target/site/surefire-report.html的文件。

如果您只是从命令行运行,那么我认为这将为您提供所需的功能。如果您正在使用像Jenkins或Hudson这样的CI服务器,那么我建议您查看Sonar服务器及其报告。