1

How to cover the method call inside assertThrows in the code coverage using JUnit 5 and spring boot?

out of all my code only this piece is not covered. Want to cover this as well.

enter image description here

enter image description here

Shakthi
  • 826
  • 3
  • 15
  • 33
  • 1
    Are you tracking code coverage on your tests? Isn't that an inception test? – João Dias Aug 26 '21 at 17:57
  • Code coverage by default scans all the code and shows the percentage. Just thought to cover this as well. Just a POC. But, expecting as good to know. – Shakthi Aug 26 '21 at 18:03
  • I don't recall JaCoCo doing that by default, but I might be wrong. Nevertheless, does the concept of tracking code coverage on your Test make sense to you? – João Dias Aug 26 '21 at 18:07
  • Updated the question with my implementation and the report. Jacoco covers the Test as well. Excluding, test is not a problem. But, is it now way we can cover this piece? – Shakthi Aug 26 '21 at 18:15
  • Ok, so two things about that in my opinion. 1. It makes no sense to track coverage of your tests. In fact, how does JaCoCo computes that? And then again, does this concept make sense to you? 2. Do not focus too much on Code Coverage or aim for 100%. Long story short even if you have 100% Code Coverage it does not guarantee that there are 0 bugs (check this very detailed answer https://stackoverflow.com/a/3123841/16572295). – João Dias Aug 26 '21 at 18:33
  • Yeah. I agree with your point. Thank you João Dias – Shakthi Aug 26 '21 at 22:37

0 Answers0