NonConstructableSubClass extends NonConstructableBaseClassWithField { public static NonConstructableSubClass newInstance() throws NoSuchMethodException { return NonConstructableBaseClassWithField.newInstance(NonConstructableSubClass.class, 5); } NonConstructableSubClass(int argA, int argB, int argC);  NonConstructableSubClass(int argA); static NonConstructableSubClass newInstance(); static NonConstructableSubClass newInstance(int argA); static NonConstructableSubClass newInstance(int argA, int argB, int argC); int getFieldB(); int getFieldC();  }
@Test public void shouldCreateBaseClassInstanceEvenWithSubclassNewInstance() throws NoSuchMethodException { final NonConstructableBaseClassWithField instance = NonConstructableBaseClassWithField.newInstance(NonConstructableBaseClassWithField.class, 5); assertThat(valueOf(instance.getFieldA()), is(5)); }
@Test public void shouldCreateBaseClassInstance() throws NoSuchMethodException { final NonConstructableBaseClassWithField instance = NonConstructableBaseClassWithField.newInstance(5); assertThat(valueOf(instance.getFieldA()), is(5)); }