#109 Impossible to get 100% coverage of tests with asserts

open
CORE (51)
5
2009-08-09
2009-08-09
No

EclEmma, latest version.

JDK latest version 6-15

When running coverage tests, I'm in the habit of running them on my unit
tests in addition to the code under test. This has allowed me to catch code
in unit tests that I thought was behaving a certain way but turned out not
to.

But EMMA won't let me do that. Consider code like this:

wordsManager = new WordsManager(mDataAccessor, new
PriorityWordsFilter(3, 2, true));
assertIsTrue(wordsManager.getNotificationMode() ==
WordsManager.NOTIFICATION_MODE_NO_CHANGE);
assertNotNull(wordsManager.getPriorityWords());
assertIsTrue(wordsManager.getPriorityWords().length == 0);
wordsManager.updatePriorityWordsFilter(new PriorityWordsFilter(3,
2, true));
assertIsTrue(wordsManager.getNotificationMode() ==
WordsManager.NOTIFICATION_MODE_NO_CHANGE);
assertNotNull(wordsManager.getPriorityWords());
assertIsTrue(wordsManager.getPriorityWords().length == 0);

Each of the lines with an equality test is marked yellow, not covered, by
EMMA. But of *course* the expressions are only going to evaluated to true
or to false--that's the whole point of passing them into the asserts.
That's how JUnit works!

Note that this is not a duplicate of bug #2762627.

Discussion


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks