Difference between shims and stubs

前端 未结 4 1007
孤街浪徒
孤街浪徒 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 10:08

    As a general guide, use stubs for calls within your Visual Studio solution, and shims for calls to other referenced assemblies. This is because within your own solution it is good practice to decouple the components by defining interfaces in the way that stubbing requires. But external assemblies such as System.dll typically are not provided with separate interface definitions, so you must use shims instead.

    It's very good reference.

提交回复
热议问题