Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft Fakes and .Net 4.0

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?

like image 851
gmancoll Avatar asked Sep 10 '12 13:09

gmancoll


2 Answers

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:

  • http://blog.pluralsight.com/2012/05/22/solid-code-for-solid-reasons/

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.

like image 173
Jim Cooper Avatar answered Oct 05 '22 14:10

Jim Cooper


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.

like image 43
Pavel Tsybulivskyi Avatar answered Oct 05 '22 13:10

Pavel Tsybulivskyi