??????????????л?????????????????????絥?????UT?????????Integration Test??????????end-to-end ????

????????????????????????????????????????????????δ????????????????塣

??????????????xx????????????????????????????????????????????????????

?????????????????????????????????????????????????д?????У?????????????д?????????????

??????????????????????????????????????????????????????????????????????????????????

???????????????????????????塣???????????????ζ?????????????????????????????????????????????????

??????Щ????????????????????

????????????????????????????????????????????????????

??????????? Unit Test

??????????????壺

????A unit test is a test written by the programmer to verify that a relatively small piece of code is doing what it is intended to do. They are narrow in scope?? they should be easy to write and execute?? and their effectiveness depends on what the programmer considers to be useful. The tests are intended for the use of the programmer?? they are not directly useful to anybody else?? though?? if they do their job?? testers and users downstream should benefit from seeing less bugs.

?????????????????

????1??UT?????????д?????????????á?

????2??UT??????????С?δ??????????????????????????????????????

????????????TestNG??????????θ???UT???

????unit testing (testing a class in isolation of the others)

???????????????????UT case?????????????????????UT case?в?????????????

??????????????????????UT????????????????????????????????????κν??????????????????Mockito??mock?????????????????????????????????????????????mock??????????UT????????

????????UT ?????????????????????????

????????????????

????????????JUnit?????TestNG??.net????NUnit??VS2010????????????????

????c/c++????CppUnit??PHP????PHPUnit??

????Mockito??easyMock??mock????????????????

?????????????????????????????????????UT??????????????ж????????????????ε?????д??UT?????????????е?????????????????????д??UT?????????????????????????????

????Cobertura????????UT?????????????????????????? ?????????????????daily build????????????????

?????????????????????????????????80~90%??????????????

????1?????UT?????????е????

????????????????JUnit????????

????No?? just test everything that could reasonably break.

????Be practical and maximize your testing investment. Remember that investments in testing are equal investments in design. If defects aren't being reported and your design responds well to change?? then you're probably testing enough. If you're spending a lot of time fixing defects and your design is difficult to grow?? you should write more tests.

????If something is difficult to test?? it's usually an opportunity for a design improvement. Look to improve the design so that it's easier to test?? and by doing so a better design will usually emerge.