I have a question about good implementation of unit test with EasyMock.
First implementation:
Capture<String> capturedString = newCapture();
myService.doSomething(capture(capturedString));
expectLastCall();
assertEquals("stringValue", catpuredString.getValue());
Second implementation:
myService.doSomething("stringValue");
expectLastCall();
I feel comfortable with the first implementation because an assertion is present. But in the second implementation I expect "stringValue" passed to my service. If it's not the case an exception will be thrown by EasyMock. So is there a difference between the 2 implementations ? If not, is one better then the other ?
Thanks.
Aucun commentaire:
Enregistrer un commentaire