When to use stubs and mocks?

后端 未结 5 684
既然无缘
既然无缘 2021-01-02 10:46

I\'ve this confusion all the time. If I write a code which uses fake code to assert some operation, how do i trust my real implementation when it is started really using the

5条回答
  •  被撕碎了的回忆
    2021-01-02 11:10

    Most kinds of unit testing is about testing individual pieces of code, and stubs and mocks are simply tools that assist you in testing piece-by-piece. By testing pieces individually you can probably test each piece in greater detail, but you will not be guaranteed anything about the full picture. Various kinds of integration testing will do that.

    When testing bigger pieces of functionality, I often find actual integration tests of database logic to be the least valuable test artifacts, since you will often be testing these same operations at the UI level.

提交回复
热议问题