Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
786 views
in Technique[技术] by (71.8m points)

slf4j - logger.isDebugEnabled() is killing my code coverage. I'm planning to exclude it while running cobertura

I tried by adding in org.slf4j.* in cobertura.exclude. but there is no use.
my buildfile

require 'buildr/java/cobertura'
require 'buildr/scala'
require 'buildr/myProject'
.....
.....
compile.options.other = %w(-encoding UTF-8)
cobertura.exclude= 'org.slf4j.*'
.....
.....

Please suggest how to proceed.

Thank you in advance

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The issue is that cobertura.exclude is to exclude files/classes in your project from being instrumented.

What you want to use is cobertura.ignore, e.g.,

cobertura.ignore 'java.util.logging.*'

which accepts a regular expression of class/method name to ignore.

From the Ant task documentation at https://github.com/cobertura/cobertura/wiki/Ant-Task-Reference:

You can tell Cobertura to ignore certain classes by passing in "ignore" regular expressions. The ignore pattern can be any valid perl 5 regular expression. This will ignore any calls to any method that matches the ignore regular expression. It will NOT skip over these classes during instrumention. To exclude classes from being instrumented, either exclude them from your fileset or use the alternative method below and specify an excludeClasses pattern.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...