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

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

    OK, unit tests won't find every problem, that's why we have integration tests, too!

    But suppose you have a method that must return a value between 1 and 9 and you write a test for it and find that it returns a value of null or 10, then you know the code is broken long before you get to integration testing.

提交回复
热议问题