3

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.

Jaroslaw Pawlak
  • 5,538
  • 7
  • 30
  • 57
Tagamoga
  • 332
  • 4
  • 18
  • This could just be a question of display. Do you have a test covering the `catch` block just above that line? – ernest_k Jul 13 '18 at 11:24
  • yes. otherwise the line above the dots would not be marked green. – Tagamoga Jul 13 '18 at 11:25
  • It's a known bug - https://dotnettools-support.jetbrains.com/hc/en-us/community/posts/205835509-Closing-braces-sometimes-not-being-included-in-code-coverage – alaster Jul 13 '18 at 11:30
  • @alaster since 5 years... that is **unsatisfactory**. Would you like to post that as answer? I'll mark that... – Tagamoga Jul 13 '18 at 11:57
  • @Tagamoga posted. It's a pity that there is no normal solution – alaster Jul 13 '18 at 12:09

1 Answers1

2

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.

alaster
  • 3,821
  • 3
  • 24
  • 32
  • 1
    Or ... he could investigate the bug, find the cause, develop a fix and submit a patch. And so could you :-). Start here: https://github.com/JetBrains/intellij-community – Stephen C Jul 13 '18 at 13:20
  • 2
    @StephenC Your faith in my skills is far beyond the truth... ;-) BTW: I am a she not a he... – Tagamoga Jul 16 '18 at 06:29
  • 2
    @StephenC Oh, I understand your argument, but It is not the willingness to cooperate. I am still learning and I'm far away to achieve such fix. Perhaps someday... So much interesting things to do, so less time... And I mentioned my gender, because "he" is so naturally used for every user, that it is already unpleasing... you could heave used my name instead of "he" or "she"... I am so often addressed with "he", so it is getting rather... nasty... BTW: My gender does not affect my skills or my learning. It is a pity that you have to mention that fact in brackets... – Tagamoga Jul 16 '18 at 07:31