import org.jmock.Expectations;
import org.jmock.Mockery;
import org.junit.Test;
public class ExampleTest {
@Test
public void testMockObjectInteraction() {
Mockery mockery = new Mockery();
final MyInterface mockObject = mockery.mock(MyInterface.class);
mockery.checking(new Expectations() {{
allowing(mockObject).getValue();
will(returnValue(42));
}});
MyClass myClass = new MyClass(mockObject);
int result = myClass.getSomeValue();
mockery.assertIsSatisfied();
assertEquals(42, result);
}
}