2011-11-07 50 views
0

如何運行'mvn'。Netbeans maven-surefire-plugin不生成HTML

我使用NetBeans 7,當我跑我的單元測試,我從我的項目/目標文件夾

/target/surefire-reports/TEST-package.name.ClassNameTest.xml生成的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> 

我可以得到我的測試,經過精磨,我使用內置的單元式轉輪與Junit4在Netbeans的。

我已經遍地搜索了,我發現的所有內容都是記錄不完整的示例,而不是完整的演練,介紹如何使用測試結果生成報告HTML文件。

不知道這是否相關,但我在Windows XP下開發。 JDK 7.我使用的Maven是直接從Netbeans項目中獲得的。

我已經通過使用看過帖子和示例:

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

JUnit的報告:報告和JUnit報告,但我似乎無法找出任何的這些東西。

只是尋找一個簡單的生成的HTML文件。

回答

1

如果您運行命令mvn surefire-report:report,那麼在surefire再次運行您的測試後,您應該找到一個名爲target/site/surefire-report.html的文件。

如果你只是從命令行運行,那麼我認爲這會得到你想要的。如果您使用Jenkins或Hudson這樣的CI服務器,那麼我會建議查看Sonar服務器及其報告。