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

前端 未结 5 1402
温柔的废话
温柔的废话 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:42

    I've read (and heartily recommend) The Art of Unit Testing by Roy Osherove. He uses a simplified set of terminology.

    To paraphrase his book ...

    Integration Test - any test that reaches outside of the current process or object to interact with something else

    Interaction Test - a test on the way that objects work together

    State Test - a test on the results produced by an operation

    Fake - any stand-in object that's used instead of the real thing

    Stub - a stand-in object that provides a dependency required by the code under test

    Mock - a stand-in used to check the results of the test

    Note that here both Stubs and Mocks can be provided by a Mocking framework - the distiction is as much about how they're used as the technology used.

提交回复
热议问题