Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
424 views
in Technique[技术] by (71.8m points)

c# - 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()
CoreHyperlinkParserTest.cs(59,0): at Abot.Tests.Unit.Core.HyperLinkParserTest.GetLinks_AreaTags_ReturnsLinks()

A few notes...

  • I'm using visual studio 2012 premium
  • All projects in the solution target .net 4.0
  • I'm using nunit for the testing framework
  • Tried running tests through testdriven.net plugin and nunit gui but same error.
  • Tried targeting .net 4.5 and got the same error
  • I'm NOT using Typemock or Ncrunch and they are not installed
  • I am using Moq but removed it from the th
  • Its not tied to a specific test, i've verified it fails in different test files and in another solution as well.
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...