0

我怎样才能运行'mvn'。

我正在使用 Netbeans 7,当我运行单元测试时,我确实从我的项目 /target 文件夹中获取了生成的 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 中使用内置的 Unit Runner 和 Junit4。

我到处搜索,我发现的只是记录不充分的示例,而不是关于如何使用我的测试结果生成报告 HTML 文件的完整演练。

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

我通过以下方式看到了帖子和示例:

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

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

只是寻找一个简单的生成的 HTML 文件。

4

1 回答 1

1

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

如果您只是从命令行运行,那么我认为这将为您提供您想要的。如果您使用的是 Jenkins 或 Hudson 等 CI 服务器,那么我建议您查看 Sonar 服务器及其报告。

于 2011-11-07T17:44:49.050 回答