问题描述
我们正在使用 NSubstitute 来模拟用于单元测试的外部对象.但是,许多传统类不是通过接口调用的,因此无法轻松地用模拟代替.
We are using NSubstitute to mock external objects for our unit tests. However many legacy classes are not called via interfaces and can't be easily replaced with mocks.
我已经考虑使用微软假货,但根据 "
I've considered to use Microsoft Fakes, but according to the answer for the question "Mock framework vs MS Fakes frameworks"
是否可以在同一测试中将MS Fakes垫片与NSubstitute模拟一起使用?
Would it be possible to use MS Fakes shims with NSubstitute mocks in the same tests?
我们应该期待任何兼容性问题吗?
Should we expect any compatibility problems?
推荐答案
是.我已经将Shims和NSubstitute一起使用了几个月.它在本地和构建服务器上都可以正常工作.唯一的麻烦是Resharper测试运行程序无法与Shims一起使用,因此我们必须使用VisualStudio的测试运行程序.
Yes. I've been using Shims together with NSubstitute for several months. It work fine both locally and on build server. The only trouble is Resharper test runner does not work with Shims, so we have to use VisualStudio's test runner instead.
这篇关于可以将MS Fakes垫片与NSubstitute模拟一起使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!