Search code examples
javaintellij-ideajunittest-coverage

Why empty line is not included in code coverage?


I am using Java 8.0, Springboot and Junit.

After writing my unit tests for my Application class I get following stats:

Application class: Line Coverage: 95% (22/23)

So I looked after the line and get:

enter image description here

Marked with pink dots, this is the line that "ruins" my coverage. It is an EMPTY line with one closing bracket!!!

Why is that count at All? It cannot be stepped over, otherwise I will never get a return value! Wow! What is happening here?

Thanks for help!

P.S.: I don't care about the coverage, but I am VERY curious, what happened here.


Solution

  • It's a known bug.

    Very sad that there are so old unfixed bugs. You could try a workaround posted in this thread or just leave code as is.