An overview of unit testing terminology ( stub vs mock , integration vs. interaction )?

前端 未结 5 1391
温柔的废话
温柔的废话 2021-01-30 04:33

I\'m using more unit tests in my projects and reading all the information I can online and am getting confused by a lot of the terminology. As a result I\'m probably using these

5条回答
  •  隐瞒了意图╮
    2021-01-30 04:58

    Fowler did of course a great work at differentiating Mocks and Stubs but, to me, the XUnit Test Patterns book is the reference and I'd suggest to check Mocks, Fakes, Stubs and Dummies for a comprehensive comparison.

    Yeah, I know, this is confusing and that's why I'd suggest checking Mocks and Stubs aren't Spies, then let’s spy and finally Mockito - The New Mock Framework on the Block too.

    Regarding the different types of tests, a simplified explanation could be (this is not an exhaustive list):

    • unit testing: testing a single "unit", a method, in isolation
    • integration testing: testing the integration of several units (methods, classes, components, layers)
    • functional testing: testing an end-to-end scenario (from a user perspective)

    All these types are useful and not exclusive, they actually just don't have the same intent.

提交回复
热议问题