2015-10-20 36 views
9

Maven版本:3.3.3。 FindBugs的插件版本:3.0.1Maven Findbugs插件 - 如何在測試類上運行findbug

  1. 我使用的findbugs-maven-plugin,我需要運行FindBugs的對src和測試類 插件。目前,它只適用於源類

    Target 
    |_ classes 
    |_ test-classes 
    |_ findbugs (only have results regarding classes folder) 
    
  2. 我需要爲PMD插件做同樣的事情。也許同樣的提示?

相關的問題:

FindBugs的Maven配置:

<profile> 
    <id>findbugs</id> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>findbugs-maven-plugin</artifactId> 
       <version>${findbugs.version}</version> 
       <configuration> 
        <effort>Max</effort> 
        <failOnError>true</failOnError> 
        <threshold>Low</threshold> 
        <xmlOutput>true</xmlOutput> 
        <includeTests>true</includeTests> 
        <excludeFilterFile>findbugs-exclude.xml</excludeFilterFile> 
       </configuration> 
       <executions> 
        <execution> 
         <id>analyze-compile</id> 
         <phase>verify</phase> 
         <goals> 
          <goal>check</goal> 
          <goal>findbugs</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</profile> 

回答

7

在的配置,您需要將includeTests元素明確地設置爲true爲FindBugs的分析測試類:

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>findbugs-maven-plugin</artifactId> 
    <version>3.0.1</version> 
    <configuration> 
    <!-- rest of configuration --> 
    <includeTests>true</includeTests> 
    </configuration> 
</plugin> 

而且,這樣的FindBugs是源和測試類的編譯後執行的插件應該被綁定到verify階段。

對於maven-pmd-plugin,它實際上是相同的:元素includeTests必須在插件配置中設置爲true

+0

非常感謝,但我們現在有135個錯誤(在測試中),而不是有0個錯誤(在src中)。 – Leonel

相關問題