Exclude specific methods from code coverage from cobertura?
Asked Answered
T

1

16

I was trying to ignore all the toString() methods from instrumentation using following configuration. This wasn't really working? This is using cobertura as maven plugin. This was based on a previous answer Exclude methods from code coverage with Cobertura.

<instrumentation>
    <ignores>
        <ignore>toString</ignore>
    </ignores>
</instrumentation>

What do you think I'm doing wrong. I wasn't able to find an example for this on the cobertura documentation.

Take answered 23/8, 2010 at 5:2 Comment(1)
You might want to consider the only answer offeredStipule
N
3

cobertura-ant reference

"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."

<cobertura-instrument todir="${instrumented.dir}">
    <ignore regex="org.apache.log4j.*" />
    ...
</cobertura-instrument>

I believe you have to change "ignores" to "ignore" and use a regular expression to define the whole class name before the method (or just an * in you case to exclude toString from any class).

Newcomen answered 8/10, 2012 at 8:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.