title: Jacoco code coverage: non-existent Static block shows only 75% coverage
body: <p>I have two static methods in the class BrickSortParallel. They are fully covered by unit tests. But I have a static block <code>static {...}</code>  listed with only 75% code coverage by Jacoco. What does that signify?</p>
  <p><img src="https://i.stack.imgur.com/O61oi.jpg" alt="Screen shot of coverage" /></p>
  <pre class="lang-java prettyprint-override"><code>
  public static int computeOddTaskCount(int length) {
      if (length &lt; 0) throw new IllegalArgumentException(&quot;Illegal argument value: &quot; + length);
      return isOdd(length) ? length &gt;&gt; 1 : abs(length - 1) &gt;&gt; 1;
    }
  
    public static int computeEvenTaskCount(int length) {
      if (length &lt; 0) throw new IllegalArgumentException(&quot;Illegal argument value: &quot; + length);
      return length &gt;&gt; 1;
    }
  </code></pre>
  <p>Following are test cases to ensure full code coverage for above methods:</p>
  <pre class="lang-java prettyprint-override"><code>class ComputeTaskCountTest {
  
  private static final String ZERO_TASKS_EXPECTED = &quot;Zero tasks expected.&quot;;
    private static final String ONE_TASK_EXPECTED = &quot;One task expected.&quot;;
    private static final String HALF_TASKS_EXPECTED = &quot;Half tasks expected.&quot;;
    private static final String ILLEGAL_LENGTH_EXPECTED = &quot;Illegal length expected.&quot;;
  
      @Test
      @DisplayName(&quot;BrickSortParallelTest.ComputeTaskCountTest.testZeroLength&quot;)
      void testZeroLength() {
        assertEquals(0, computeOddTaskCount(0), ZERO_TASKS_EXPECTED);
        assertEquals(0, computeEvenTaskCount(0), ZERO_TASKS_EXPECTED);
      }
  
      @Test
      @DisplayName(&quot;BrickSortParallelTest.ComputeTaskCountTest.testMinusOneLength&quot;)
      void testMinusOneLength() {
        assertThrows(
            IllegalArgumentException.class, () -&gt; computeOddTaskCount(-1), ILLEGAL_LENGTH_EXPECTED);
        assertThrows(
            IllegalArgumentException.class, () -&gt; computeEvenTaskCount(-1), ILLEGAL_LENGTH_EXPECTED);
      }
  
      @Test
      @DisplayName(&quot;BrickSortParallelTest.ComputeTaskCountTest.testMinusTwoLength&quot;)
      void testMinusTwoLength() {
        assertThrows(
            IllegalArgumentException.class, () -&gt; computeOddTaskCount(-2), ILLEGAL_LENGTH_EXPECTED);
        assertThrows(
            IllegalArgumentException.class, () -&gt; computeEvenTaskCount(-2), ILLEGAL_LENGTH_EXPECTED);
      }
  
      @Test
      @DisplayName(&quot;BrickSortParallelTest.ComputeTaskCountTest.testMinValueLength&quot;)
      void testMinValueLength() {
        assertThrows(
            IllegalArgumentException.class,
            () -&gt; computeOddTaskCount(Integer.MIN_VALUE),
            ILLEGAL_LENGTH_EXPECTED);
        assertThrows(
            IllegalArgumentException.class,
            () -&gt; computeEvenTaskCount(Integer.MIN_VALUE),
            ILLEGAL_LENGTH_EXPECTED);
      }
  
      @Test
      @DisplayName(&quot;BrickSortParallelTest.ComputeTaskCountTest.testOneValueLength&quot;)
      void testOneValueLength() {
        assertEquals(0, computeOddTaskCount(1), ZERO_TASKS_EXPECTED);
        assertEquals(0, computeEvenTaskCount(1), ZERO_TASKS_EXPECTED);
      }
  
      @Test
      @DisplayName(&quot;BrickSortParallelTest.ComputeTaskCountTest.testTwoValueLength&quot;)
      void testTwoValueLength() {
        assertEquals(0, computeOddTaskCount(2), ZERO_TASKS_EXPECTED);
        assertEquals(1, computeEvenTaskCount(2), ONE_TASK_EXPECTED);
      }
  
      @Test
      @DisplayName(&quot;BrickSortParallelTest.ComputeTaskCountTest.testThreeValueLength&quot;)
      void testThreeValueLength() {
        assertEquals(1, computeOddTaskCount(3), ONE_TASK_EXPECTED);
        assertEquals(1, computeEvenTaskCount(3), ONE_TASK_EXPECTED);
      }
  
      @Test
      @DisplayName(&quot;BrickSortParallelTest.ComputeTaskCountTest.testFourValueLength&quot;)
      void testFourValueLength() {
        assertEquals(1, computeOddTaskCount(4), ONE_TASK_EXPECTED);
        assertEquals(2, computeEvenTaskCount(4), &quot;Two tasks expected&quot;);
      }
  
      @Test
      @DisplayName(&quot;BrickSortParallelTest.ComputeTaskCountTest.testMaxValueLength&quot;)
      void testMaxValueLength() {
        assertEquals(
            Integer.MAX_VALUE / 2, computeOddTaskCount(Integer.MAX_VALUE), HALF_TASKS_EXPECTED);
        assertEquals(
            Integer.MAX_VALUE / 2, computeEvenTaskCount(Integer.MAX_VALUE), HALF_TASKS_EXPECTED);
      }
  
      @Test
      @DisplayName(&quot;BrickSortParallelTest.ComputeTaskCountTest.testMaxValueLengthEven&quot;)
      void testMaxValueLengthEven() {
        assertEquals(
            (Integer.MAX_VALUE - 2) / 2,
            computeOddTaskCount(Integer.MAX_VALUE - 1),
            HALF_TASKS_EXPECTED);
        assertEquals(
            (Integer.MAX_VALUE - 1) / 2,
            computeEvenTaskCount(Integer.MAX_VALUE - 1),
            HALF_TASKS_EXPECTED);
      }
    }
  
  </code></pre>
  <p>Am I missing anything in the above test class?</p>
  <p>The full classes are available at:</p>
  <p><a href="https://raw.githubusercontent.com/Fernal73/DSAlgos/master/src/test/java/ds/tests/BrickSortParallelTest.java" rel="nofollow noreferrer">https://raw.githubusercontent.com/Fernal73/DSAlgos/master/src/test/java/ds/tests/BrickSortParallelTest.java</a></p>
  <p><a href="https://raw.githubusercontent.com/Fernal73/DSAlgos/master/src/main/java/ds/BrickSortParallel.java" rel="nofollow noreferrer">https://raw.githubusercontent.com/Fernal73/DSAlgos/master/src/main/java/ds/BrickSortParallel.java</a></p>
  <pre><code>$ java --version
  openjdk 11.0.8 2020-07-14
  OpenJDK Runtime Environment (build 11.0.8+10)
  OpenJDK 64-Bit Server VM (build 11.0.8+10, mixed mode)
  </code></pre>
  <p>Jacoco version: 0.85</p>
  <p>From the report, the static block has a cyclomatic complexity of 2 and with only one branch covered, that implies there's a <a href="https://www.eclemma.org/jacoco/trunk/doc/counters.html" rel="nofollow noreferrer">test case missing to cover that eventuality</a>.</p>