Different coverage statistics for Set and Map for similar utility methods

10 views
Skip to first unread message

namann...@gmail.com

unread,
Apr 7, 2017, 9:36:22 AM4/7/17
to JaCoCo and EclEmma Users
Bringing this from Issues to the forum.

Steps to reproduce

public class Utils {

public static boolean isNotNullOrEmpty(Map map) {
return map != null && !map.isEmpty();
}

public static boolean isNotNullOrEmpty(Set set) {
return set != null && !set.isEmpty();
}
}
For which I wrote a unit tests as follows -

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class UtilsTest {

@Test
void testUtils() {
assertNotNull(new Utils());
assertFalse(Utils.isNotNullOrEmpty(new HashMap()), "Map utils failure.");
assertFalse(Utils.isNotNullOrEmpty(new HashSet()), "Set utils failure.");
}
}
JaCoCo version:0.7.9
Operating system:MacOSX
Tool integration: Maven

Expected behaviour

The coverage for the isNotNullOrEmpty(Set set) should also be 100%.

Actual behaviour

The branch coverage is 50%.

External Link - http://stackoverflow.com/questions/43264560/jacoco-code-coverage-difference-for-set-and-map

Why is there such an incosistency for Set vs Map util defined in our code.

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages