What should I consider when choosing a mocking framework for .Net

后端 未结 8 1975
梦如初夏
梦如初夏 2020-12-12 18:20

There are lots of mocking frameworks out there for .Net. There is no clear winner that has superseded the others in every way. The leading mocking frameworks also have many

相关标签:
8条回答
  • 2020-12-12 19:01

    stubs looks interesting and I think it may ship with .NET V4. I don’t know witch edition of developer studio you will need to use it. At present you can download it from the above link.

    Stubs is a lightweight framework for test stubs and detours in .NET that is enterily based on delegates, type safe, refactorable and source code generated. Stubs was designed support the Code Contracts runtime writter and provide a minimal overhead to the Pex white box analysis. Stubs may be used on any .NET method, including non-virtual/static methods in sealed types.

    (I have posted this as an answser rathern then adding it to the quesion, as I have never used Stabs and only spend a few minutes looking at it)

    0 讨论(0)
  • 2020-12-12 19:02

    I prefer Moq for .NET 3.5 projects. It is simple to use and, in my experience, it helps to produce clean and clear unit tests.

    There's no technical reason why you can't use more than one mocking framework on the same project. Sure, it's nice to standardize, but some tests may lend themselves better to some frameworks.

    0 讨论(0)
提交回复
热议问题