Why should I bother with unit testing if I can just use integration tests?

前端 未结 12 1358
别那么骄傲
别那么骄傲 2021-02-03 21:53

Ok, I know I am going out on a limb making a statement like that, so my question is for everyone to convince me I am wrong. Take this scenario:

I have method A, which ca

12条回答
  •  粉色の甜心
    2021-02-03 22:15

    I agree with you that in your simple case, there is no need for unit tests. Testing (unit, integration, functional, regression) are all dependent on the size of your project and the number of people involved and the level of experience of everyone involved.

    As any of these factors increase (well, the last one would have to decrease), then the need for testing increases. You need to find a solution that is appropriate and applicable to your particular project.

    I am a big fan of unit tests and believe that all developers should write and automate them regardless of the size of the project. They will ensure that your code is bug free and will really help when you return to the proejct after several months.

    I also believe that as you have multiple people working on the project over an extended period of time (read anything other than a throw-away project) then you also need automated integration tests to ensure that the various components work together.

提交回复
热议问题