I would like to exclude hashCode
and equals
from clover report.
Some configuration example would be nice.
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:
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:
We use the following LocalEqualsHashCodeTest
which can be extended by a unit test:
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:
© 2022 - 2024 — McMap. All rights reserved.