Search for the best openworks Mocking framework for .net

I know this is pretty subjective, but I dive into testing and find out the mockery, and I'm trying to figure out which structure I should use. If you could tell me which ones you recommended, and most importantly why it is better than the others that you used , I would say. Or, if anyone knows where I can get a side-by-side comparison, which will also be useful.

+5
source share
6 answers

Moq is the most advanced. It uses all the features of .NET 3.5 and C # 3.0. It would be interesting:

+7

Rhino.Mocks, Moq NMock. Moq.

NSubstitute... , , .

:

[Test]
public void SomeOtherTest()
{
    //Arrange
    var mock = new Mock<IFoo>();
    var sut = new SystemUnderTest(mock.Object); //never liked doing it this way...
    mock.Setup(m => x.Bar()).Returns("A whole bunch of ceremonial syntax..");
    //Act
    sut.DoSomething();
    //Assert
    mock.Verify(m => m.Baz()); //Baaaaah, more laaaaambdas
}

--eryness

[Test]
public void NSubTest()
{
    var mock = Substitute.For<IFoo>();
    var sut = new SystemUnderTest(mock); //much nicer!
    mock.Bar().Returns("Look ma! No lambdas!");

    sut.DoSomething();

    mock.Received().Baz();
}

.. github...

http://nsubstitute.github.com/

+6

RhinoMocks. AAA (Arrange-Act-Assert). RhinoMocks . lambdas , LINQ. . , , , , , , . , "" , , . . , , framework, , . , RhinoMocks.

+3
source

You can find a useful article by Richard Banks comparing mocking frameworks .

Note . In the interest of full disclosure, I am a co-author of NSubstitute , which comes out pretty profitably in comparison. :)

+1
source

I used NMock and find it excellent. http://www.nmock.org/

However, this is the only one I used.

0
source

All Articles