Maven Findbugs插件 - 如何在测试类上运行findbug [英] Maven Findbugs plugin - How to run findbug on the test classes
问题描述
Maven版本:3.3.3。 Findbugs插件版本:3.0.1
Maven version: 3.3.3. Findbugs plugin version: 3.0.1
-
我正在使用
findbugs-maven-plugin
我需要在src和测试类上运行findbugs
插件。目前,它仅适用于源类
I'm using the
findbugs-maven-plugin
and I need to run findbugs plugin on src and test classes. Currently, it is only applied to the source classes
Target
|_ classes
|_ test-classes
|_ findbugs (only have results regarding classes folder)
我需要为PMD插件做同样的事情。同样的提示可能吗?
I need to do the same for the PMD plugin. Same hint maybe?
相关问题:
- FindBugs filter file for ignoring JUnit tests
- How to run findbug on the test code
Findbugs maven配置:
Findbugs maven configuration:
<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>
推荐答案
在的配置中findbugs-maven-plugin
,你需要明确地设置 includeTests
元素到 true
,以便FindBugs分析测试类:
In the configuration of the findbugs-maven-plugin
, you need to explicitely set the includeTests
element to true
for FindBugs to analyze the test classes:
<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。
Also, the plugin should be bound to the verify
phase so that FindBugs is executed after compilation of source and test classes.
对于 maven-pmd-plugin
,它实际上是相同的:元素 <$ c必须在插件配置中将$ c> includeTests 设置为 true
。
For the maven-pmd-plugin
, it is actually the same: the element includeTests
must be set to true
in the plugin configuration.
这篇关于Maven Findbugs插件 - 如何在测试类上运行findbug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!