Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ShimNotSupportedException when running tests from MSTest or Resharper

I am currently working with Microsoft Visual Studio 2012 and the new Fakes framework. And after adding my unit tests to the MSBuild and continuous integration process, the Fakes unit tests happen to raise a ShimNotSupportedException.

I tried different stuff and read into that issue and found out that, this only happens when I run my tests from the Resharper feature, or directly in the code with MSTest. These exceptions DO NOT occur when running from the Test menu bar, which made me think about checking the setting files of this features.

After further research I found some articles where it says that it might has something to do with the code coverage setting specified in the Resharper or MSTest settings and if you switch that off, it solves the issue. ShimNotSupportedException in MS VisualStudio 2012 also relates to that problem.

I also found some input on the MSDN about that issue, which confirmed me that it has to do something with the code coverage: http://social.msdn.microsoft.com/Forums/en-US/vstest/thread/17fcfdc6-1cda-4692-a242-656b48195327/ and http://social.msdn.microsoft.com/Forums/en-US/vstest/thread/bfa792b0-b3fc-4a51-b49d-f7aaf1f2f4b8.

Nevertheless, since I have to implement code coverage into the continuous integration process somehow soon, and skipping that part is not an option, I am now asking here for any advice regarding this issue, and if there is any kind of solution to that problem!

Thanks for all advice!

like image 290
Thomas Mondel Avatar asked Aug 18 '12 18:08

Thomas Mondel


People also ask

Does Visual Studio use MSTest or VSTest?

The Visual Studio Tests build runner integrates functionality of the MSTest framework and VSTest console runner. Support for both frameworks enables TeamCity to execute tests and automatically import their test results.

Does MSTest run tests in parallel?

The biggest advantage of MSTest is that it allows parallelization at the method level. As opposed to the other frameworks which only allow parallelization at the class level. So, for example, If you have 100 test methods in 5 classes, MSTest will let you run 100 tests in parallel.

How do I run unit tests with ReSharper?

Ctrl+U D on the toolbar. Ctrl+U D commands, which are also available in the main menu (ReSharper | Unit Tests) and in the context menu. To run or debug all tests in solution, choose ReSharper | Unit Tests | Run All Tests from Solution in the main menu or press Ctrl+U L .

What is difference between NUnit and MSTest?

MsTest is a native unit testing library that comes with Visual Studio from Microsoft. NUnit is an extra Nuget package that needs to be installed on top and interact with the APIs of Visual Studio. Nunit likely doesn't have direct integration into the native APIs like MsTest does.


1 Answers

Fakes is not supported by MsTest: http://msdn.microsoft.com/en-us/library/ms253138.aspx.

Here's how you can run the Visual Studio Testrunner from Team City (which supports Fakes): http://blog.degree.no/2012/09/unit-testing-visual-studio-2012-fakes-in-team-city/

You can also use the Visual Studio Testrunner if you use TFS.

like image 110
Njål Arne Gjermundshaug Avatar answered Oct 13 '22 03:10

Njål Arne Gjermundshaug