Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Ignore coverage for java core assertions, Eclipse Eclemma

I have a question regarding Eclemma plugin configuration: In production code I have a lot of java core assertions, like:

assert arr.size() == 2 : "message";

When I am running Eclemma on my unit tests, it shows low coverage because of yellow marks on assertions. Idea of placing asserts is not to have possibilities to end up with negative-case of the assertion (It should never happen!), they are just code quality guards, nothing more. But Eclemma in the other hand, thinks that these negative cases are not covered branches of the statement (which is marazmatic :) ), therefore it marks them yellow.

So, The question is: How can I configure Eclemma to ignore "assert" code lines in the coverage report?

like image 233
haykart Avatar asked Feb 13 '17 09:02

haykart


1 Answers

EclEmma - is Eclipse plugin based on Java Code Coverage Library called JaCoCo. JaCoCo performs analysis of bytecode, and unfortunately doesn't have yet filtering for the bytecode that compiler generates for assert.

like image 168
Godin Avatar answered Nov 01 '22 12:11

Godin