I would like to exclude hashCode
and equals
from clover report.
Some configuration example would be nice.
I would like to exclude hashCode and equals from clover report.
I would respectfully suggest that you actually test these methods instead of avoiding them. Serious bugs can occur if they are not consistent with specifications. I've encountered NPEs and other problems in poorly written hashCode
and equals
methods as well. Here's a great link with a number of ways that you can test your methods:
How should one unit test the hashCode-equals contract?
We use the following LocalEqualsHashCodeTest
which can be extended by a unit test:
http://pastebin.com/L03fHAjv
You then define a createInstance()
method which returns an instance of your class and a createNotEqualInstance()
method which returns another instance that is not equal to the first one.
You have to do two steps:
1) Define method contexts in the <clover-setup> task containing regular expressions for methods you want to match, for example:
<clover-setup ...>
<methodContext name="equals" regexp="public boolean equals\(.*\)"/>
<methodContext name="hashCode" regexp="public int hashCode\(\)"/>
</clover-setup>
2) Define which method contexts shall be excluded from the report in the <clover-report> task
<clover-report>
<current outfile="clover_html" title="My Coverage">
<format type="html" filter="equals,hashCode"/>
</current>
More information:
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