???MOCK??????е??????????????
???????????? ???????[ 2012/11/28 13:23:20 ] ????????
1.??????????
?????????????????????????????????С????????????????????????????????????????????Щ??????????????????????????????????????????Servlet??????????????????????
?????????????????????????????????????????????????????????????????£??????С???????????????????????????????????????????????????????????????????л????????????????????????????????????????????е?Υ???????????????????????????????????????????????????????????????????????????????3????????????????????????????????????????????????????????????????????????????????????????????????й????????????????е??????????????????????????
?????????????????????????????????????????????????У?????????????????????????????????????????й?????????????????????е??????????????????????????????????????????????????????????????????????????ЩС???????????????A?????????????B????????????????????????????????????????A????????????????????????£??????????????????????????????????????????????????????????????????????????????????????????????
??????????????????????????????????mock????Mock????????????????????????????
2.???????Mock??????
????????????????Mock????Tim Mackinnon?????????Щ???飺
----- ?????????в???????????(??????????????????????????)
----- ???????????????(????????web????)
----- ?????????Щ??????????(???????????)
----- ??????????????????????
----- ????????????????
----- ???????????????????????α??????(???????????????????????????????????)
----- ???????????????????(???????????????С?飬?????μ??????????????????????????????)
3.??????Mock????
???????mock??????в?????????????????3?????裬??????
----- ??????????????????????
----- ?????????????????
----- ????????????mock???????????????
???????????????ο???????????????????????????????????????????????????????????????????????????????????????????mock???????濴?????????????????????????????????????????????????5????????????????????°??????????????????????????????????????????????????????????????...??????????????????????????mock?????????в???????????????????????????????????????????????5???????
?????????
public interface Environmental {
private boolean playedWav = false;
public long getTime();
public void playWavFile(String fileName);
public boolean wavWasPlayed();
public void resetWav();
}
???????????
public class SystemEnvironment implements Environmental {
public long getTime() {
return System.currentTimeMillis();
}
public void playWavFile(String fileName) {
playedWav = true;
}
public boolean wavWasPlayed() {
return playedWav;
}
public void resetWav() {
playedWav = false;
}
}
??????mock????
public class MockSystemEnvironment implements Environmental {
private long currentTime;
public long getTime() {
return currentTime;
}
public void setTime(long currentTime) {
this.currentTime = currentTime;
}
public void playWavFile(String fileName) {
playedWav = true;
}
public boolean wavWasPlayed() {
return playedWav;
}
public void resetWav() {
playedWav = false;
}
}
??????
???·???
??????????????????
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