by Njål

Visual Studio 2012 Fakes – ShimNotSupportedException when debugging tests

 

image

When testing VS2012 Ultimate I tried to use the new Microsoft Fakes framework to mock a simple static method. Running the test went fine, but I kept getting a ShimNotSupportedException when debugging the test. 

After goggling and trying all kinds of stuff I finally managed to debug the test by following these steps:

  1. Deleted the local.testsettings file (both in VS and on disk)

  2. Deleted the <solution>.vsmdi file (both in VS and on disk)
  3. Made sure IntelliTrace had these settings (not sure if this mattered):

    image

  4. Restarted VS2012
  5. Made sure that no .testsettings file were selected here

    image

Debugging of tests now works fine!
(Running/debugging the tests from Resharper still does not work – but I can live with this.)

I tried to add a new .testsettings file (with CodeAnalysis and everything else disabled) – but this makes the ShimNotSupportedException reappear again.

Similar Fakes/ShimNotSupportedException/Debug issues have been reported to MS, so I hope they get this resolved soon.

———————————————————————————————————–

Another sad fact is that the Fakes framework is only available in the Ultimate edition of Visual Studio 2012 – which retails at over USD 13,000. This makes absolutely no sense at all. ALL developers should use unit testing as part of their tool belt – and isolating tests using a mocking framework plays a key role. Microsoft Moles could be used for free in the previous VS 2010 version – and it worked great. This is very disappointing.

Please vote for this issue here: http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2919309-provide-microsoft-fakes-with-all-visual-studio-edi

Comments

6 Comments
  • Pingback: Unit testing – Visual Studio 2012 Fakes in Team City | Degree Blogg

  • smwikipedia Says:

    same exception, but your solution doesn’t work. I have met many nasty VS2012 abnormal issues, it seems VS2012 is a half-baked product.

    Patrick Tseng Says:

    You can add a runSettings file which wraps your .testsettings files to run your test (ref. http://msdn.microsoft.com/en-us/library/jj635153.aspx ). In the runSettings file (e.g My.RunSettings), specify the following

    yourVS2010.testsettings
    false
    true

    This should allow your fake tests to be debugged under VS2012.
    Regards,
    Patrick Tseng MSFT

    crazy0man Says:

    Your solution works for me.
    But from my side, it doesn’t need to disable the InteliTrace.

    I can run test case successfully with VSTS test exporler.
    But failed to run test with resharper test tools.

    Andreas Says:

    Deleting local.testsettings and .vsmdi worked for me.