Is it possible to assing value to mock object. Ex:
myMockObject = context.mock(MyObject.class);
myMockObject.setId("someId");
My method which I'm testing reaches the end, but at the end there is method for validation of that object so object without id is considered to be invalid. Is there anything else I can do about this?
Can I somehow specify ok I'm expecting this exception but pass the test anyway?
I found this link but I'm unable to found solution :
http://www.jmock.org/yoga.html
I'm expecting logger to throw an validation exception with message string, did anyone have experience with this before?
I tried this :
context.checking(new Expectations() {
{
allowing(logger).error(with(exceptionMessage));
}
});
Note exceptionMessage message is thrown by the validation method which validates the object at the end of the method which I'm testing.