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

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

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

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.

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
Community showcase
Published 5 hours ago in Jira Ops

Jira Ops Early Access Program Update #1: Announcing our next feature and a new integration

Thanks for signing up for Jira Ops! I’m Matt Ryall, leader for the Jira Ops product team at Atlassian. Since this is a brand new product, we’ll be delivering improvements quickly and sharing updates...

113 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you