【发布时间】:2013-05-15 21:55:59
【问题描述】:
我正在尝试使用 Microsoft Shims 运行此单元测试,但它在 Shims.Context.Create(); 方法中引发了异常。
环境: VS 2012,Win2K8 R2
namespace MyShimsUnitTest
{
[TestClass]
public class MyUnitTest
{
[TestMethod]
public void GetCurrentYear()
{
using (Microsoft.QualityTools.Testing.Fakes.ShimsContext.Create())
{
// Some Logic...
}
}
}
}
详细异常:
Result Message:
Test method MyShimsUnitTest.MyUnitTest.GetCurrentYear threw exception:
Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException: UnitTestIsolation instrumentation failed to initialize. Please restart Visual Studio and rerun this test
Result StackTrace:
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.InitializeUnitTestIsolationInstrumentationProvider()
at Microsoft.QualityTools.Testing.Fakes.Shims.ShimRuntime.CreateContext()
at Microsoft.QualityTools.Testing.Fakes.ShimsContext.Create()
at MyShimsUnitTest.MyUnitTest.GetCurrentYear()
【问题讨论】:
-
您能否确认您已按照建议操作(重新启动 Visual Studio)
-
@DaveRook:是的,我已经重新启动了我的 VS,但没有运气。
-
@skumar:你用哪个测试运行器来运行上面的测试?
-
@skumar -- 如果你要去create a tag wiki 和copy the text verbatim from another source without attribution,那就是抄袭,会被标记为抄袭。 请在创建标签wiki时注明来源。
-
@LittleBobbyTables:感谢您的反馈。我会牢记并在未来遵循它。再次感谢。
标签: c# unit-testing microsoft-fakes