Home / Posts tagged "NMock2"

NMock2 Release with MockStyle.Stub?

We got the following geek question from Henrik:

Hi,

Thanks for sharing this preview of the MockStyle.Stub feature!
Its exactly was I was looking for when I googled this page,
so now I just can't wait for a release with this included ;-)

I tried to find some information on futre release plans but could not find any.
Could anybody help me out? When could we3 expect a new NUnit
supporting MockStyle.Stub?

Cheers!

Henrik

The answer to this question is a bit complicated. Let me tell you why:

The current development team of NMock2 (Thomas, Peter and me) will not actively continue to develop NMock2. We’ll still provide basic support (bug fixes) but no new features. However, we have planned to make one last release (including the Stub feature) when we are sure that it works in our projects. This will be soon because we didn’t have a new defect in the last two months or so.

The reason why we have lost interest is that Moq has gained a lot of momentum and has a much broader community support. Furthermore, Moq provides some basic improvements that we cannot simply add to NMock2: besides the type safe, refactoring friendlier syntax, it allows very clean AAA (Arrange, Act, Assert) unit tests.

On the other side, there exists the NMock3 project on CodePlex that adds a type-safe syntax wrapper around NMock2. Check it out, when you already use NMock2 in your project.

So for short: the release including the Stub feature will be available soon, but it will also be the last release.

If you can’t wait until the official release then get the code from the subversion repository and start the build.release.cmd, et voila!

Happy mocking (whatever framework you use)

Urs

Mocking Adventures with NMock2: Stubs Advanced

NMock2 is a library for assisting test driven development of .NET code by providing a dynamic mock object creation framework.

In my last post on NMock2, I introduced the new Stub feature of NMock2 and its basic usage. In the second part, we are going to have a look at the advanced possibilities of the Stub mock style:

  • Define Mock Style Of Nested Mocks
  • Define Default Values

Continue reading

NMock2 Documentation Now On MediaWiki

Due to changes on sourceforge.net and its hosted applications, the documentation of NMock2 – a library for assisting test driven development of .NET code by providing a dynamic Mock Object framework for .NET interfaces and classes (virtual and abstract members of classes) – has been moved from WikiSpaces to MediaWiki.

You can check it out at http://sourceforge.net/apps/mediawiki/nmock2/index.php?title=Main_Page

Mocking Adventures with NMock2: Stubs

NMock2 is a library for assisting test driven development of .NET code by providing a dynamic mock object creation framework.

In this article, I’m going to show you the basics of the new stub feature in NMock2. Note that this feature is currently only available on the development trunk in the subversion repository at https://nmock2.svn.sourceforge.net/svnroot/nmock2/trunk. Therefore, the features discussed here may change for the next official release.

Stubs can be used in scenarios where you have to test an instance of a class (let’s call this object testee) and this testee makes calls to another object (dependency) but you simply do not care what the testee calls on the dependency because it is not relevant for your test case.

Stubs will simply ignore any calls to it and if the call has a return value then the stub provides a default value.

Continue reading

NMock2 is fast. Really fast!

Andrew Kazyrevich published a post containing timing comparisons of Moq, Rhino Mocks, Isolator and NMock2.

And NMock2 – although still lacking some features – is very fast compared to the competitors. Woohoo!

I’m curious how the newly introduced features (mock classes, non-strict and recursive mocks) will change in this setup. I’ll check that out as soon as I find some time :-O

If you want to check the new features (alpha!) yourself then here is the svn URL: https://nmock2.svn.sourceforge.net/svnroot/nmock2/branches/nonstrictmocks

Happy mocking!

NMock2 Release Candidate Version 2.0 is out

The first release candidate of version 2.0 of NMock2 – a .net dynamic mocking framework – is published.

Check it out at: sourceforge.net

You can provide feedback at: NMock2 forum

Release Notes:

  • virtual/abstract classes can now be mocked (with default or transparent mock style)
  • Stack traces of exceptions thrown in event handlers of events fired on mocks are preserved
  • Source is now on Visual Studio 2008 (target framework is still .net 2.0)
  • Events of inherited interfaces can now be fired on mocks
  • internal interfaces of signed assemblies can now be mocked (contribution of Matthias Weibel)
  • Swallowed exceptions are rethrown in VerifyAllExpectationsHaveBeenMet