title: How to include the Catch block in code coverage : JaCoCo and Junit
body: <p>I'm quite new to Junit and JaCoCo. I'm trying to <strong>add test case for the catch block</strong>. But my JaCoCo code coverage is still asking me to cover the catch block in code coverage.
  Following is my method and testcase.</p>
  <pre><code>public Student addStudent(Student Stu) throws CustomException {
      try {
          // My Business Logic
          return Student;
      } catch (Exception e) {
          throw new CustomException(&quot;Exception while Adding Student &quot;, e);
      }
  }
  
  @SneakyThrows
  @Test
  public void cautionRunTimeException(){
      when(studentService.addStudent(student)).thenThrow(RuntimeException.class);
      assertThrows(RuntimeException.class,()-&gt; studentService.addStudent(student));
      verify(studentService).addStudent(student);
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/XaBOg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XaBOg.png" alt="enter image description here" /></a></p>
  <p>Please share me the correct way for the code coverage of catch block.</p>
  <p>Note: JaCoCo version: 0.8.5, Junit version; junit5, Java version: 11</p>