Developers have to test classes like this.
public class DoAnything { private Object fieldA; private Object fieldB; private Object fieldC; public void doAnyComplex() { doThat1(); . . . doThatN(); } protected void doThatX() { if (fieldA.equals(fieldB)) { fieldA = newValueAX; fieldB = newValueBX; fieldC = newValueCX; } else { ... } } }Every doThatX method is complex, depends on the values of the private members and change theire values. Testing such a class requires special efforts. The developer can change the accessibility from private to package. Or he can write special public methods calling the non public members. In both cases the class design conforms to requirements of writing tests.
This project suggest an other way:
public void testDoThatX() { AccessObject doAnythingObj = AccessFactory.instanciate(DoAnything.class); AccessField fieldA = doAnythingObj.getField("fieldA"); AccessField fieldB = doAnythingObj.getField("fieldB"); AccessField fieldC = doAnythingObj.getField("fieldC"); AccessMethod doThatX = doAnythingObj.getMethod("doThatX"); fieldA.setValue(startValueA); fieldB.setValue(startValueB); fieldC.setValue(startValueC); doThatX.call(); //voidCall doThatX.call(param1,param2); doThatX.call(new Object[] {param1,...,paramN}); assertEquals(expectedA,fieldA.getValue()); fieldB.assertEquals(expectedB); }