16

test/* ファイルではなく src/* ファイルのみをスキャンする findbugs ant スクリプト用のフィルター ファイルを設定する必要があります。

名前に「test」が含まれるファイル名またはパッケージ名を無視して、すべてのクラスをチェックするための構文は何ですか?

4

2 に答える 2

23

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> 

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> 

where exclude.xml looks like:

<FindBugsFilter>
  <Match>
    <Class name="~.*Test$"/>
  </Match>
  <Match>
    <Package name="~test\..*"/>
  </Match>
</FindBugsFilter>
于 2009-04-16T16:00:29.413 に答える
-1

ちなみに、FindBugs で単体テストもカバーすることをお勧めします。テストに低い品質基準を使用する理由はありません。テストのバグは、まさにバグです。

確かに、FindBugs を初めて実行した場合は、多くのバグ レポートが表示される可能性がありますが、注意を払えば、時間の経過とともにバグの数は減少します。

于 2010-06-12T03:29:17.590 に答える