[Java] Function call shown as not covered when exception is thrown

Report shows line as not covered by tests when called function throws exception.

void test1() {
  test2();    // this line is shown as having no coverage

void test2() throws MyException {
  throw new MyException();


  • Enterprise Edition
  • Version 8.9.6 (build 50800)

Hey there.

SonarQube doesn’t generate coverage reports, it only reads the ones that are passed to it. Does the coverage report generated for your project (by JaCoCo, presumably) indicate that the line is covered?

Oh, my bad! Yes, it’s coming from JaCoCo, I was not aware of it. Please discard this issue then. Sorry!

1 Like