Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Is it possible to exlude methods from coverage metrics based on complexity? (maven)

Nick Harvey October 8, 2014

There are a large number of bean classes in a project that I'm working on, (in the 100s), and I'd like to be able to exclude the simple property methods from code coverage metrics. I had been excluding all bean classes at first, then switched to excluding property methods.

The problem with both of these is that some of the beans have at least a small amount of logic in the getter and setter methods; these I feel should be considered for code coverage metrics.

Ideally, I would be able to exclude any methods that are < 3 lines and have a complexity of 1, but I've been unable to find a way to do this in Clover for Maven.

1 answer

0 votes
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 8, 2014

Hi Nick,

You can exclude certain methods based on their number of statements or complexity, but only using Clover-for-Ant - see the <clover-setup> / <methodContext> element, the 'statements' / 'aggregatedStatements' / 'complexity' / 'aggregatedComplexity' attributes.

In case of Clover-for-Maven, the configuration option is simplified and you can define only method's name using a regular expression. There is an improvement request raised to add statements and complexity attributes:

https://jira.atlassian.com/browse/CLOV-1173

and it's scheduled for Clover 4.1.1 at the moment (end of 2015 probably); but feel free to contribute if you need this urgently - sources are on https://bitbucket.org/atlassian/maven-clover2-plugin/.

 

Cheers
Marek

Nick Harvey October 8, 2014

Thanks Marek - it's not really urgent, just trying to convince my team of the value of these metrics, and figure the more accurate they are the easier that will be. I may take a look at the source - thanks for the link.

Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 8, 2014

I case you'd decide to check sources - it's in com.atlassian.maven.plugin.clover.internal.AbstractCloverInstrumentMojo. Cheers!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events