??????????????????????????????????Щ??????λ?????????????????????????????????TDD??????????е???????????????????????????????С?
????1????????????????????
????Quora??????????????In Test Driven Development?? how do unit tests help drive good design?
????Ken Beck??????????
????TDD doesn't drive good design. TDD gives you immediate feedback about what is likely to be bad design. If a test is hard to write?? if a test is non-deterministic?? if a test is slow?? then something is wrong with the design. When I'm not ready to make good design decisions?? I still don't end up with a good design?? but I certainly know I have room for improvement.
??????????????TDD????????????????????TDD???в???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????鱾???????????????????????????????????????????????????????????д?????????
??????????????????м????????????
????-???????λBug?????????????????д???????????
????-???????????????????????????Bug???????
????-??????????????????
????2??????к?????д??????????
???????????????????????????к?????д?????????????????????????????:
????-?????????????????????????????????????????????д??????д????????
????-?д??????????????????????????
????-?д??????????????????б???е???????????????????
????-???????????????Ч????
??????????????????????????????
????3??????д????????
???????????????????????????????????????Щ??????????????????á?Junit Recipes??????J. B. Rainsberger???????
????1.When writing a test?? start with what you want to check?? then write just enough code to compute that result.
????2.Don't perform multiple actions in the same test. Test one action at a time.
????3.Don't assume that you have to group tests for the same function or object together.
????4.Don't test the platform; worry about your stuff.
????4?????????????????????
??????д???????????????????????????????????????????
????1.??????????????????????????????????????????????UT?????Щ??????????????????UT??????????????????UT????????????????
????2.??????????????????£?????????????????????UT??
????3.???????С?????????????д????????
??????????????????????????????????????????????????е????????????????????????????????????Э?????????????????????????????????????????????????????????????????????????????????????????
????5??????
????????????????????????????????????????????????????????????????????????????????????UT???????????????????????????UT?????????????????????????????????????????????????????????????????????????????????????????а??ж??UT?????????????е?????????????д???????????????????????????????????????????UT??????????????
??????????棬??????????????????????UT?????????????UT?? UT??????????????????????????????????????????????????????