刚刚安装了 vs 2012 更新 2 ( http://www.microsoft.com/en-us/download/details.aspx?id=36833 ) 所以我可以使用 vs fakes/shims 来测试一些难以测试的代码。当我创建假程序集并且所有引用都按预期添加到单元测试项目中时,一切都编译得很好。但是在任何测试中运行以下代码......
using (ShimsContext.Create())
{
//Doesn't matter whats in here
}
引发以下异常...
Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException : UnitTestIsolation instrumentation failed to initialize. Please restart Visual Studio and rerun this test
堆栈跟踪的完全异常...
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()
一些笔记...
- 我正在使用 Visual Studio 2012 高级版
- 解决方案中的所有项目都针对 .net 4.0
- 我正在使用 nunit 作为测试框架
- 尝试通过 testdriven.net 插件和 nunit gui 运行测试,但同样的错误。
- 尝试定位 .net 4.5 并得到相同的错误
- 我没有使用 Typemock 或 Ncrunch 并且它们没有安装
- 我正在使用起订量,但将其从 th 中删除
- 它与特定测试无关,我已经验证它在不同的测试文件和另一个解决方案中都失败了。