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...
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.
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}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With