????????е?α????
???????????? ???????[ 2015/7/8 16:47:21 ] ??????????????? ?????????
??????????????????α????????á?????????з??????????????????????????????????????????????
????EasyMock???????????????????????????????????????????????α????α??????????????????????е???в?????????????塣EasyMock????java.lang.reflect.Proxy????????????????????????????????????????????Proxy?????????????????????????????????α????
????Mocquer???????????????????????EasyMock?????????????????α????
????Mocquer????
????Mocquer????Dunamis????????????????????????????????????????????????????EasyMock???????????????淶????????????ò????????????
????MockControl??Mocquer????????????????????????α????????????????????塣?????????????????
????1??????????????????
????·public void replay();
????·public void verify();
????·public void reset();
????α??????????????????????????????????????????????????1?????α??????????????
????Figure 1. Mock object life cycle
??????????α?????????????????????????????????塣replay()?????α????????????????????????????α???????????y?????????????????????????verify()???ú?α????????????MockControl????α???????????????????????????????????????????MockControl????????????????????????????????????????replay()????????????????????κ????μ???reset()??????????????????????????????
????2??????????
????·public static MockControl createNiceControl(...);
????·public static MockControl createControl(...);
????·public static MockControl createStrictControl(...);
????Mocquer????????MockControl?????????????????????????????????????????????и?????????????????????????з????????????????????MockControl???????MockControl????????????????α?????з???????????????δ??????????????????????????????????????????????????MockControl??????MockControl???Щ??δ??????????????AssertionFailedError????????MockControl??????????α???????????·????????????????????????????AssertionFailedError?????±????????????MockControl??????
????????????????????????????????汾??
????public static MockControl createXXXControl(Class clazz); public static MockControl createXXXControl(Class clazz?? Class[] argTypes?? Object[] args);????????????????????????????????????????????????????????汾?????????á??????????汾??????????????????????????????????????磬???? ClassWithNoDefaultConstructor???????????????????? public class ClassWithNoDefaultConstructor { public ClassWithNoDefaultConstructor(int i) { ... } ... }·α??????????
????public Object getMock();
????????MockControl????????????α????????á?????????????????????????α??????????????????????
????//get mock control MockControl control = MockControl.createControl(Foo.class); //Get the mock object from mock control Foo foo = (Foo) control.getMock();·??????巽??
????public void setReturnValue(... value);
????public void setThrowable(Throwable throwable);
????public void setVoidCallable();
????public void setDefaultReturnValue(... value);
????public void setDefaultThrowable(Throwable throwable);
????public void setDefaultVoidCallable();
????public void setMatcher(ArgumentsMatcher matcher);
????public void setDefaultMatcher(ArgumentsMatcher matcher);
????MockControl??????????????α????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11