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

后端 未结 12 825
轻奢々
轻奢々 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:50

    There are many reasons to unit test code. The main reason I would advocate unit testing after the fact is simple. Your code is broken, you just don't know it yet.

    There is a very simple rule in software. If the code is not tested, it's broken. This may not be immediately obvious at first, but as you begin testing, you will find bugs. It's up to you to determine how much you care about finding these bugs.

    Besides this, there are several other important benefits of unit testing,

    • regression testing will be made simpler
    • other developers, that are less knowledgeable, can't break your desired behavior
    • the tests are a form of self documentation
    • can reduce time in future modifications (no more manual testing?, less bugs?)

    The list can go on and on. The only real drawback is the time it takes to write these tests. I believe that drawback will always be offset by the time it takes you to debug problems you could have found while unit testing!

提交回复
热议问题