Question

we've been looking into using the new Fakes framework to help us increase the test coverage on some legacy code running under the .net 4.0 framework. Unfortunately, it seems like we're going to be unable to upgrade to .net 4.5. Would I be correct in saying that we cannot use the Fakes framework with .net 4.0 (and VS2012) and that we'd need to use the now unsupported Moles framework instead?

Was it helpful?

Solution

Although I'm not a fan of moles in general, I understand the help they can be in getting tests around legacy code. Below are some other tools you can consider. But seriously, I hate these types of frameworks because the right way to do things is to write code that is testable and refactor legacy code that isn't (I understand that this isn't always easy or possible). I think moles gets rid of the one of the major benefits of unit testing, which is that it forces you to write good code as discussed here:

Here are a couple of things to consider:

  • Moles (Predecssor to MS Fakes Framework)
  • JustMock (Less expensive than TypeMock, but still expensive)
  • TypeMock (Rediculously expensive!)

There is also a free, light version of JustMock, not sure what it includes.

OTHER TIPS

You should use Visual Studio 2012 Ultimate or Premium Update 2 to be able to use Microsoft Fakes, and unit tests can target earlier versions of .NET framework.

I know this isn't what you asked, but have you considered/evaluated non-microsoft mocking frameworks?

Rhino.Mocks is incredibly popular and robust, and FakeItEasy is growing in adoption. It's documentation isn't as rich, but it is incredibly intuitive and easy to use.

I'm test 3.5 assemblies with fakes, the fakes tests it self are compiled for 4.5. I haven't tried to compile them for 3.5, but the are not intended to run on the deployment machine.

Microsoft Fakes framework supports the same .NET versions as Visual Studio 2012 itself. This includes versions 4.5, 4.0, 3.5, 3.0 and 2.0.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top