Coverage Report in Java 8

I just started working with Java 8. I see a lot of threads and options. One question arose in my head. Consider the following example taken from this oracle textbook :

String name = computer.flatMap(Computer::getSoundcard) .flatMap(Soundcard::getUSB) .map(USB::getVersion) .orElse("UNKNOWN"); 

Or the following, taken from here :

 List<String> myList = new ArrayList(); myList .stream() .filter(s -> s.startsWith("c")) .map(String::toUpperCase) .sorted() .forEach(System.out::println); 

Is there any coverage solution that can tell me if orElse was used in the first snippet? Or some other that tells me that closing the filter was not called at all since the list is empty? Can any report that the method reference in forEach not used?

+7
java java-8 unit-testing code-coverage
source share
1 answer

At least Clover seems to support coverage for closures. See this blog post!

Example in Intellij:

enter image description here

+1
source share

All Articles