I am new using mocks , specially jMock (for java). I've done some testing before but not with mock and I am wondering what is the correct way to make them.
For example, I have a service with the implementation.. so, I have this service test. At the server test I have my methods.
Lets say I have methodA on serviceHelperTest , and as part of methodA I have this
ArrayList someValues = serviceHelperImpl.otherMethod
So, as far as I know, I should mock this serviceHelperImpl.othermethod, because I don't really care if is good or not, it is supposed to return some values.
So, let's say I expect a boolean value, is it possible to do this?
public myMethodToTest(){
mockery.checking(new Expectations() {
{
oneOf(serviceHelper).otherMethod();
will(returnValue(true));
}
});
Boolean myVar = serviceHelper.otherMethod();
...
}
I dont know if this is correct or not... any idea how mocks should be implemented on testing units?
Aucun commentaire:
Enregistrer un commentaire