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.
The easiest way to exclude code from code coverage analysis is to use ExcludeFromCodeCoverage attribute. This attribute tells tooling that class or some of its members are not planned to be covered with tests. EditFormModel class shown above can be left out from code coverage by simply adding the attribute.
You can set lombok. addLombokGeneratedAnnotation = true into lombok. config in the root of project. After that, all Lombok-generated code will be ignored by Jacoco.
Cobertura is a free Java tool that calculates the percentage of code accessed by tests. It can be used to identify which parts of your Java program are lacking test coverage. It is based on jcoverage.
Test classes (classes that are annotated with @isTest ) are excluded from the code coverage calculation. This exclusion applies to all test classes regardless of what they contain—test methods or utility methods used for testing.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With