Test-driven development is an important practice in agile methods. It is generally considered to be the father of extreme programming.Kent BeckCreated 《Test-driven development by exampleThe book has been elaborated in detail. However, as many software technologies and methods emerge,TDDIt can also be regarded as the crystallization of the wisdom of everyone. Among them, there is no lack of early andKentbeckActive togetherSmalltalkCommunityAnd now the most prestigious industry leaders, such:Erich Gamma,Ward cunnheim, AndMartin FowlerAnd others. There are so many senior personnel for support, presumablyTDDThe value is beyond doubt.
TypicalTDDThe steps are as follows:
LYou can quickly compile a test case as needed. At this time, even compilation fails.
LWrite as few features as possibleCodeTo pass the test case
LTest Cases are gradually supplemented as needed. At this time, the test cases still fail.
LModify the function code to pass the new test cases. At the same time, you must re-pass the previously passed and failed test cases.
LRefactor the code of the above functions (sometimes even test code) to eliminate duplicates.
Advantages of test-driven development:
LProviding effective assurance for System Improvement
LIt is very helpful for improving the design.
LProvides a good "document" for functional code"
LTo some extent, it can be replacedProgramDebugging
LIt can significantly increase developers' confidence and win others' trust.