??????????????
????????????
?????????Wikipedia ?????????
????????????е???????????????????з???????
??????????????з??????????飬????С??????в????????????????????У?unit ???????? class/method??
????????? unit ???????????????????? mock/stub ???????????stub??mock???????????martinfowler??????Mocks Aren’t Stubs??
?????????????????в????????д??
???????????????????????????????????OOP??????????????????????????
????State????????????????????????????????
????Behavior??????????????????????????????????????
????Unit testing ???????????????????????? state assert ?? behavior verification??
??????????????????????????е?λ??
???????????????????????????Σ???????????????У?

?????????????????????????????????/??鸚???
?????????????????????????????絥???????
????e??????????????????????????????????????????????????????????????????????к????????
??????????????????????????????????????????й????
??????????????
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????д???????????????????????????????
?????????????????????????????????????????????????д????????????????????????????????????д???????Ч??????
????????????????????????????????????????????????????????????????
?????????????????????????????????????????????
???????”?????????”?У???????????????????????????????п???????????????????????????bugfix??????????????????????£?Google testing: Just Say No to More End-to-End Tests??


??

?????????????????
????mock???????????????????д???????????
????????????????????????????????????????????????????????????????????
??????????????б????е????????????????????????
????????????????????????????????????????????????????淶????????????????????????????????????????в????淶????
????????????????
????1?????????????淶

??????????
??src/
?????????? main
??????   ?????? java
??????   ?????? resources
?????????? test
?????????? java
?????????? resources
?????????ο?maven????????
??????????????
??// ????????Test??β
????public class TokenServiceTest extends AbstractTestCase {
????@Resource
????private TokenService tokenService;
????// ??????????Test??β
????@Test
????public void insertTest() {
????MockUp<TokenDao> tokenDaoMockUp = new MockUp<TokenDao>() {
????@Mock
????Integer insert(Token token) {
????return 1;
????}
????};
????ReflectionTestUtils.setField(tokenService?? "tokenDao"?? tokenDaoMockUp.getMockInstance());
????tokenService.insert();
????}
????}
???????????????????????????????????????????д?????????????????????
????1) web??
??????? PATH??REQUEST_METHOD ??????????????? RESPONSE_CODE???????????????????????????????????????к?????????????????????????
????2) facade??
???????????У?飬????????????????????
????3) service/component??
???????????????????????????????mock??????????????
????4) cache??
?????????????????????????????д??????????????????????????????????????
????5) dao??
???????sql?????????????????????????????????????????????????????????
????????????????
??????????????????????????У???е???????????review?????
????2????????????????
????????????Щ?????????????????????о????????????????????
????TestNG: a testing framework inspired from JUnit and NUnit but introducing some new functionalities?? ?????http://testng.org/doc/
????jmockit: includes APIs for mocking?? faking?? and integration testing?? and a code coverage tool. ?????http://jmockit.org/about.html??API ???????£?

????3??????????
???????????????????????????????????????????????????
?????????????
????????????????????????£???????????????????