How do you retrofit unit tests into a code base?

前端 未结 7 683
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-17 16:56

Do you have any strategies for retrofitting unit tests onto a code base that currently has no unit tests ?

7条回答
  •  孤城傲影
    2021-01-17 17:36

    Dale gets voted up. Yes, there is no gain for adding unit tests to code that's working. Lets say there are two unknown bugs X & Y. At some point X is revealed by typical field use. You fix it, add a unit test, and move on. Now lets assume Y is never uncovered over the entire lifetime of the program. Since Y never revealed itself it's as if it never existed; no need to waste the resources. Multiply this by hundreds or thousands of dormant bugs and you save yourself a great deal of superfluous maintenance.

提交回复
热议问题