Pro's and Con's of unit testing after the fact

后端 未结 12 826
轻奢々
轻奢々 2021-02-03 18:43

I have a largish complex app around 27k lines. Its essentially a rule drive multithreaded processing engine, without giving too much away Its been partially tested as it\'s been

12条回答
  •  天涯浪人
    2021-02-03 18:47

    Pro post facto unit testing:

    • Get documentation you can trust.
    • Improve understanding of the code.
    • Push toward refactoring and improving the code itself.
    • Fix bugs that lurk in the code.

    Con post facto unit testing:

    • Waste time fixing bugs you can live with. (If you wrote 27KLOC, we hope it does something, right?)
    • Spend time understanding and refactoring code you don't need to understand.
    • Lose time that could go into the next project.

    The unasked question is just how important an asset is this code to your organization, long term? The answer to this question determines how much you should invest. I have plenty of (successful) competitors where the major purpose of their code is to get out numbers to evaluate some new technique or idea. Once they have the numbers, the code is of little marginal value. They (rightly) test very carefully to make sure the numbers are meaningful. After that, if there are fifty open bugs that don't affect the numbers, they don't care. And why should they? The code has served its purpose.

提交回复
热议问题