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

前端 未结 12 1348
别那么骄傲
别那么骄傲 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:18

    Unit testing is finer grained and allows you to pinpoint errors. What if A or B failed? How would you know which one failed if your integration test failed? And that's only 2 methods -- imagine if you are integration testing a front controller of a web application, which loads a handful of models and calls a bunch of methods. That would be a nightmare trying to track down exactly what went wrong.

提交回复
热议问题