Difference between shims and stubs

前端 未结 4 1005
孤街浪徒
孤街浪徒 2021-01-11 09:32

Can anyone tell me very clearly what\'s the main difference between a shim and a stub during unit testing?

I know about mock objects and I

4条回答
  •  悲&欢浪女
    2021-01-11 09:50

    From what I understood, the difference is where the mocked code resides or which part of code you mocked (i.e. the "where" gives the distinction). So I would put it as:

    You call Stub the part of your code which you mocked while it will be called Shim if you mock some external call.

    • "your code" being the code to be tested
    • "external call" is the dependency on which your code depends

    I found this reference good: My two cents on fakes, stubs, mocks, and shims esp the part "A general rule is to take advantage of stubs for internal calls and shims for external assemblies."

提交回复
热议问题