sjdirect
sjdirect

Reputation: 2364

Visual Studio 2012 fakes UnitTestIsolation instrumentation failed to initialize

Just installed vs 2012 update 2 (http://www.microsoft.com/en-us/download/details.aspx?id=36833) so I can use vs fakes/shims to test some hard to test code. Everything compiles just fine when I create the fake assemblies and all references are added within the unit test project as expected. However running the following code in any test...

using (ShimsContext.Create())
{
    //Doesn't matter whats in here
}

Throws the following exception...

Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException : UnitTestIsolation instrumentation failed to initialize.  Please restart Visual Studio and rerun this test

Full exception with stack trace...

Test 'Abot.Tests.Unit.Core.HapHyperLinkParserTest.HyperLinkParserTest.GetLinks_AreaTags_ReturnsLinks' failed: Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException : UnitTestIsolation instrumentation failed to initialize. Please restart Visual Studio and rerun this test
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.InitializeUnitTestIsolationInstrumentationProvider()
at Microsoft.QualityTools.Testing.Fakes.Shims.ShimRuntime.CreateContext()
at Microsoft.QualityTools.Testing.Fakes.ShimsContext.Create()
Core\HyperlinkParserTest.cs(59,0): at Abot.Tests.Unit.Core.HyperLinkParserTest.GetLinks_AreaTags_ReturnsLinks()

A few notes...

Upvotes: 8

Views: 6492

Answers (3)

sjdirect
sjdirect

Reputation: 2364

Matthew was correct. You have to use the vs test runner.

-Had to install the NUnit Test Adapter 0.94 through the extension manager which allows vs test runner to run nunit.

-Had to use the vs test explorer window to run the tests.

Looks like the test running wraps the running tests in a context to make the fakes magic happen.

Upvotes: 9

Udit Gupta
Udit Gupta

Reputation: 101

Reset your exceptions settings under debug:

Menu debug -> Exceptions -> Reset All.

Once I changed the exception setting by unchecking in debug mode:

"Break when this exception type is user-unhandled"

Which caused this issue.

Upvotes: 0

lgrosales
lgrosales

Reputation: 589

Also, if you want to run the tests from a CI server, you will need to execute the VS Test Runner from the console, and also specify that you want to use the nUnit discoverer extension.

The command would be something like this:

{ProgramFiles}\Microsoft Visual Studio\11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow>vstest.console.exe /inIsolation /UseVsixExtensions:true {testsPath}

Upvotes: 2

Related Questions