FindBugs的过滤器文件忽视JUnit测试 [英] FindBugs filter file for ignoring JUnit tests

查看:1399
本文介绍了FindBugs的过滤器文件忽视JUnit测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要设置为我FindBugs的过滤器文件Ant脚本扫描只能在src / *文件和不测试/ *文件。

I need to set up a filter file for my findbugs ant script that scans only the src/* files and not the test/* files.

什么是检查所有类而忽略在名称中使用'测试'的任何文件名或包的名称语法?

What is the syntax for checking all classes while ignoring any filename or package name with 'test' in the name?

感谢

推荐答案

FindBugs的实际扫描编译的类文件,而不是 SOURCEPATH 。如果您正在编译您的src / *和测试/ *文件到不同的目录,你可以只使用嵌套的<类...> 元素。

FindBugs is actually scanning the compiled class files, not the sourcePath. If you are compiling your src/* and test/* files to the different directories, you could just use the nested <class...> element.

<findbugs home="${findbugs.dir}" output="xml:withMessages" 
    outputFile="${findbugs.report.xml}" jvmargs="-Xmx256M" 
    effort="max" projectName="${ant.project.name}" 
    auxClasspathRef="findbugs.classpath" 
    sourcePath="${src.dir}">
  <class location="${src.classes.dir}"/>
</findbugs>

如果SRC / *和测试都编译为一个单一的目录/ *这是行不通的。在这种情况下,使用过滤文件并排除对应的测试包或类名。

That won't work if src/* and test/* are both compiled to a single directory. In that case, use a filter file and exclude the packages or class names that correspond to tests.

<findbugs home="${findbugs.dir}" output="xml:withMessages" 
    outputFile="${findbugs.report.xml}" jvmargs="-Xmx256M" 
    effort="max" projectName="${ant.project.name}" 
    auxClasspathRef="findbugs.classpath" 
    sourcePath="${src.dir}"
    excludefilter="exclude.xml">
  <class location="${classes.dir}"/>
</findbugs>

其中, exclude.xml 如下:

<FindBugsFilter>
  <Match>
    <Class name="~.*Test$"/>
  </Match>
  <Match>
    <Package name="~test\..*"/>
  </Match>
</FindBugsFilter>

这篇关于FindBugs的过滤器文件忽视JUnit测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆