Having the following class:
class ToTest{ @Autowired private Service service; public String make(){
I would like to add a test that claims that service.execute is called with an object with parameter X.
I would do it with verification. I want to mock this call and make it return something verifiable. I do it with anticipation.
@Tested ToTest toTest; @Injected Service service; new NonStrictExpectations(){ { service.exceute((CertainObject)any) result = "b"; } }; toTest.make(); new Verifications(){ { CertainObject obj; service.exceute(obj = withCapture()) assertEquals("a",obj.getParam()); } };
I get a null pointer to obj.getParam (). Verification does not seem to work. If I delete the expected action, but then I get a null pointer in the inverted .toString ().
How do you guys do this job?
source share