2

Is it possible to get code coverage for a test (lines of code which test goes through) with JUnit 5 API? Or it's possible to get code coverage with IntelliJ Idea API? Code coverage info needs to be callable from code.

Thanks for help

William Brach
  • 51
  • 1
  • 3
  • 1
    I don't think it is something JUnit does. You need some external tool that would perform static code analysis. – Amongalen Mar 04 '20 at 11:51
  • 1
    With `intelliJ` next to the `Run` and `Debug` buttons, you have a `Run with coverage` button – Bentaye Mar 04 '20 at 12:04
  • Possible duplicates: https://stackoverflow.com/questions/3469661/junit-how-to-determine-level-of-code-coverage and https://stackoverflow.com/questions/14855605/maven-code-coverage-report-for-junit-test – y_ug Mar 04 '20 at 12:13

1 Answers1

2

William - You may use JaCoCo, Cobertura or similar tools to get the code coverage. Even some IDE like IntelliJ IDEA has code coverage plugins