Hide
it would be convenient, and potentially easier to read, if mock objects were automatically 'unwrapped'. This code:
mockParent.returns(mockChild.getMock()).getChild();
could instead be written as:
mockParent.returns(mockChild).getChild();
Since code-under-test would never expect an org.unitils.mock.Mock instance, it would be nice if returns() automatically called getMock() for us.
One fast way to implement this: add overloads in MockObject and the Mock interface:
public T returns(Mock<?> mock) {
return returns(mock.getMock());
}
public T onceReturns(Mock<?> mock) {
return onceReturns(mock.getMock());
}
Show
it would be convenient, and potentially easier to read, if mock objects were automatically 'unwrapped'. This code:
mockParent.returns(mockChild.getMock()).getChild();
could instead be written as:
mockParent.returns(mockChild).getChild();
Since code-under-test would never expect an org.unitils.mock.Mock instance, it would be nice if returns() automatically called getMock() for us.
One fast way to implement this: add overloads in MockObject and the Mock interface:
public T returns(Mock<?> mock) {
return returns(mock.getMock());
}
public T onceReturns(Mock<?> mock) {
return onceReturns(mock.getMock());
}