Dependency Injection: Turtles all the way down?

后端 未结 5 860
执笔经年
执笔经年 2020-12-01 18:11

So I\'m wondering about how unit testing works in regards to dealing external dependencies. Here and elsewhere I\'ve become familiar with dependency injection, and how that

5条回答
  •  佛祖请我去吃肉
    2020-12-01 19:15

    I'd like to stress out that in case of unit testing you should have two separate sets of tests: one for Foo.doSomethingWithExternalDependency and another one for Bar.doSomethingWithFoo. In the latter set create mock implementaion of Foo and you test just doSomethingWithFoo assuming that doSomethingWithExternalDependency works properly. You test doSomethingWithExternalDependency in a separate test set.

提交回复
热议问题