How can I test a class like this (see code below)?
public final class A {
public static final String FIRST = "1st";
public static final String SECOND = "2nd";
private A() {
// NOP
}
}
For now all my coverage tools say that constructor isn't covered with tests. My tests look like on this:
assertEquals(A.FIRST, "1st");
assertEquals(A.SECOND, "2nd");
How can I test my class?
UPD
This code solved my problem.
@Test
public void magic() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
Constructor<A> constructor = A.class.getDeclaredConstructor();
constructor.setAccessible(true);
A instance = constructor.newInstance();
assertNotNull(instance);
}
Yes, I agree that this isn't the best solution. But it works :)