import org.jmock.Expectations; import org.jmock.Mockery; import org.junit.Test; public class StubObjectTest { @Test public void testStubObject() { Mockery context = new Mockery(); final MyObject myObject = context.mock(MyObject.class); context.checking(new Expectations() {{ allowing(myObject).getValue(); will(returnValue(10)); }}); MyClass myClass = new MyClass(myObject); int result = myClass.calculate(); assertEquals(20, result); context.assertIsSatisfied(); } }


上一篇:
下一篇:
切换中文