.NET Mocking Frameworks, a comparison
Last updated
Last updated
Mocking framework is used to create replacement objects like Fakes, Stubs and Mocks. It is used to isolate each dependency and help developers in performing unit testing in a concise, quick and reliable way.
Creating mock objects manually is difficult and time consuming so to increase your productivity you can go for automatic generating of mock objects by using a mocking framework. A developer can build his/her unit test by using any of one NUnit, MbUnit, MSTest, xUnit etc. unit test framework and can further test it on a mocking framework.
1) NSubstitute
NSubstitute is a free and open source mocking framework. NSubstitute creates friendly substitute for .Net mocking libraries. It is designed for Arrange-Act-Assert (AAA) testing. Source Code: Testing Type: Arrange-Act-Assert (AAA)
2) Moq
This is a popular mocking framework for .Net. This mocking framework proves to be highly helpful when you are developing a Silverlight application. Moq is a simplest mocking library for .NET with a nice and simple API. It is a free and open source mocking framework. Source Code: Mock type: Supports mocking interfaces as well as classes.
3) FakeItEasy
FakeItEasy is an amazing and simple to use framework and is compatible with both C# and VB.Net. It provides nice options for fake and dummy creation and argument formatting. Also, it provides friendly API support. Source Code: