Getting error : java.lang.AssertionError: unexpected invocation: user.setUserName("John") no expectations specified: did you... - forget to start an expectation with a cardinality clause? - call a mocked method to specify the parameter of an expectation? what happened before this: nothing! at org.jmock.api.ExpectationError.unexpected(ExpectationError.java:23)
Code:
Mockery context = new JUnit4Mockery();
@Test
public void testSayHello(){
context.setImposteriser(ClassImposteriser.INSTANCE);
final User user = context.mock(User.class);
// user.setUserName("John");
context.checking(new Expectations(){{
exactly(1).of(user);
user.setUserName("John");
will(returnValue("Hello! John"));
}}
);
context.assertIsSatisfied();
/*HelloWorld helloWorld = new HelloWorld();
Assert.assertEquals(helloWorld.sayHelloToUser(user), "Hello! John");
;*/
}