2016-06-15 80 views
0

默認配置後,maven只輸出源類的Checkstyle report,而不輸出Junit測試類。注意我沒有在尋找肯定的測試報告輸出。Maven不輸出junit CHECKSTYLE報告

<reporting> 
<plugins> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-checkstyle-plugin</artifactId> 
     <version>2.17</version> 
     <reportSets> 
     <reportSet> 
      <reports> 
      <report>checkstyle</report> 
      </reports> 
     </reportSet> 
     </reportSets> 
     <configuration> 
     <configLocation>src/main/resources/apcheckstyle.xml</configLocation> 
     <module name="LineLength"> 
      <property name="max" value="120"/> 
     </module> 
     </configuration> 
    </plugin> 
</plugins> 

予改變的junit依賴性範圍從測試編譯

<dependency> 
    <groupId>junit</groupId> 
    <artifactId>junit</artifactId> 
    <version>4.12</version> 
    <scope>compile</scope> 
</dependency> 

Maven的被配置爲生成所述的CheckStyle報告

從pom.xml的

使用mvn網站插件。 我試圖添加一個用戶屬性includeTestResources爲true,但這沒有幫助。該文件指出,默認值是真的,所以我把它拿出來了。

這是checkstyle生成期間的maven輸出。

從的javadoc:

生成C:\用戶\管理\項目\ lht657aws \目標\網站\ testapidocs \求助doc.html ...

的CheckStyle插件運行:

[INFO]發電機 「的Checkstyle」 報告--- Maven的CheckStyle的-插件:2.17

[INFO]有Checkstyle 6.11.2使用src/main/resources/apcheckstyle.xml規則集報告了210個錯誤。

正在關注問題 - ?所有src下的Java是越來越加工,測試只是Java是被跳過:

[警告]無法找到來源外部參照鏈接到 - 禁用

的CheckStyle後,Maven項目信息報告開始

[INFO]發電機 「相關性」 報告--- Maven的項目信息的報告 - 插件:2.9

+0

修改以澄清這實際上是關於checkstyle報告並添加了來自Maven的輸出。 –

回答

2

Maven的神火報告插件,您的POM XML

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-report-plugin</artifactId> 
    <version>2.19.1</version> 
    <configuration> 
     <outputDirectory>path/to/the/report</outputDirectory> 
    </configuration> 
</plugin> 

而且目標surefire-report:report添加到您的Maven的通話

在這裏看到的文檔:Maven Surefire Report Plugin

編輯

我我誤解了這個問題,試着將這一部分加上你想要的配置。

<reporting> 
    <plugins> 
    <plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-checkstyle-plugin</artifactId> 
    <version>2.17</version> 
     <reportSets> 
     <reportSet> 
      <id>main_checks</id> 
      <reports> 
      <report>checkstyle</report> 
      </reports> 
      <configuration> 
      <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory> 
      <includeTestSourceDirectory>false</includeTestSourceDirectory> 
      <configLocation>config/maven_checks.xml</configLocation> 
      <outputDirectory>${project.reporting.outputDirectory}/main-checks/</outputDirectory> 
      </configuration> 
     </reportSet> 
     <reportSet> 
      <id>test_checks</id> 
      <reports> 
      <report>checkstyle</report> 
      </reports> 
      <configuration> 
      <sourceDirectory></sourceDirectory> 
      <testSourceDirectory>${project.build.testSourceDirectory}</testSourceDirectory> 
      <includeTestSourceDirectory>true</includeTestSourceDirectory> 
      <configLocation>config/sun_checks.xml</configLocation> 
      <outputDirectory>${project.reporting.outputDirectory}/test-checks/</outputDirectory> 
      </configuration> 
     </reportSet> 
     </reportSets> 
    </plugin> 
    </plugins> 
</reporting> 
+0

謝謝豪爾赫我看到這是一個普遍的問題,因爲它讓我很難找到*我*問題的答案。我對[Checkstyle報告]感興趣,(https://maven.apache.org/plugins/maven-checkstyle-plugin/index.html)不是測試報告.. –

+0

對不起,我誤解了你的問題。看看我的編輯並嘗試一下。 –

+0

謝謝!我嘗試過這個。這讓我完全走上了正軌。問題是我在'plugin'級有'configuration'節點,而不在'reportSet'級。請注意,我無法讓2.6使用我的自定義配置文件,它似乎有一個[bug](https://github.com/checkstyle/checkstyle/issues/599)重鋪。所以我在2.17。請更新您的答案,或者我可以提供答案。 –

0

Maven sure fire插件用於生成測試報告。看到這裏的其他文檔:

http://maven.apache.org/surefire/maven-surefire-report-plugin/

您需要包括這個插件在你的pom.xml,並提供路徑來創建報告(一般項目的目錄)。在進行構建時,請確保您包含此目標。

+0

我對[Checkstyle報告](https://maven.apache.org/plugins/maven-checkstyle-plugin/index.html)沒有測試報告感興趣。 Checkstyle報告評估測試類中java的語法。 –

+0

哦!我在上面John提出的壞的解決方案是完全正確的:我爲此+1。 – Lovey