Exclude method / branch from cobertura toolkit

I need to skip specific methods or code segments from the toolkit and code coverage. This led me to exclude methods from code coverage using Cobertura .

Then the cobertura ant page http://cobertura.sourceforge.net/anttaskreference.html said ... You can tell Cobertura to ignore specific classes by switching to "ignore" regular expressions. The ignore pattern can be any valid perl 5 regular expression. This ignores any calls to any method that matches the ignore regular expression. He will not skip these classes during the toolkit. To exclude classes from tools, either exclude them from the set of files , or use the alternative method below and specify the excludeClasses template. ....

From source code net.sourceforge.cobertura.ant.InstrumentTask.java

        for (int i = 0; i < ignoreBranchesRegexs.size(); i++) {
            IgnoreBranches ignoreBranchesRegex = (IgnoreBranches)ignoreBranchesRegexs.get(i);
            builder.addArg("--ignoreBranches", ignoreBranchesRegex.getRegex());
        }

What does "--ignoreBranches" do? What is the model? I am going to try this. If you used the above option, share your "command line"

+3
source share
2 answers

Please view this link. http://svnsearch.org/svnsearch/repos/COBERTURA/search?start-index=60& Apparently, the @Ignore method annotation has been added for this purpose. Regarding code blocks, I would try the same thing. Let me know if this works!

+1
source

This is not a direct answer to the question, but I take it upon myself: "Cover it." Do not exclude from coverage reports. Correct the coverage area.

0
source

All Articles