???????????????????StackOverflow?????????——“How deep are your unit tests?”???????13.8K??????(John Nolan)?????????TDD??????????????????????????????????Best Answer???????????——

????“TDD????????д??????????????????д?Щ????????????????????????????????а??????????????????????????????????????????д???????????????????????????????????????????????????????????”

??????

????StackOverflow????????????????????——

????“I get paid for code that works?? not for tests?? so my philosophy is to test as little as possible to reach a given level of confidence (I suspect this level of confidence is high compared to industry standards?? but that could just be hubris). If I don’t typically make a kind of mistake (like setting the wrong variables in a constructor)?? I don’t test for it. I do tend to make sense of test errors?? so I’m extra careful when I have logic with complicated conditionals. When coding on a team?? I modify my strategy to carefully test code that we?? collectively?? tend to get wrong.”

????????????????????????????????????????????——??????????????????????????????????????(?????????????????????????????????????????????????????????)????????????????в??????????????(?磺????????????????????)?????????????????????????????Щ??????????????????????????Щ????????????????????С??????????????У??????С????????Щ??????????????????

???????????TDD????????????????????????????Kent Beck??Kent??XP??TDD?????????????????????????????????????????????——


????The world does not think that Kent Beck would say this! There are legions of developers dutifully pursuing coverage because they think it is what Kent Beck would do! I have told many that you said?? in your XP book?? that you don’t always adhere to Test First religiously. But I’m surprised too.

??????????????????????Kent Beck????????!?????д????????????????????????????????????Щ?????????Kent Beck????????!???????????????????XP??????????????????????“??????????Test First”??????Kent???????????????!

???????滹???Щ??????Kent?? ????????????????????fight club?????????????????????????????????????????????????

????????????????Kent????????????????????????????????????????????????????????б??????д????????????????С?

??????????

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

???????????????y??

?????????????У???????????????????Щ???????????????????Щ????????

????????????У???????????????????bug report?????????bug??????и?UT?????????????????????????????????????bug ?? fixed???????????bug??????γ????

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

????????????????????????TDD?е?T??????????????D????Driven…… bla bla bla… ??????Щ????????????????????????????????????????????

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

??????????????????????? int square(int x) ??????????????????????40???????(????????????)??

?????????????????????????????????????????? void setX(int newX) ??????????????????????磺obj.z?? Obj.y???????????????????????±???????б?????

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

?????????

?????????TDD????п???????????????????????????????????????????????????Щ????г????????????????????

????1)?????????????????????????????????????????????????????????????????????!???????е????????????????????????ж???????????????????????!

????2)????????????????????????????????????????????????????????????????????б???????

????3)???????????????????????????????????????????????????????????????????????

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