title: How to add test coverage to a private constructor?
body: <p>This is the code:</p>
  
  <pre><code>package com.XXX;
  public final class Foo {
    private Foo() {
      // intentionally empty
    }
    public static int bar() {
      return 1;
    }
  }
  </code></pre>
  
  <p>This is the test:</p>
  
  <pre><code>package com.XXX;
  public FooTest {
    @Test 
    void testValidatesThatBarWorks() {
      int result = Foo.bar();
      assertEquals(1, result);
    }
    @Test(expected = java.lang.IllegalAccessException.class)
    void testValidatesThatClassFooIsNotInstantiable() {
      Class cls = Class.forName("com.XXX.Foo");
      cls.newInstance(); // exception here
    }
  }
  </code></pre>
  
  <p>Works fine, the class is tested. But Cobertura says that there is zero code coverage of the private constructor of the class. How can we add test coverage to such a private constructor?</p>