无法运行使用 Microsoft Fakes 的单元测试 - ShimsContext.Create() 方法中的异常 [英] Unable to run Unit Tests that uses Microsoft Fakes - Exception in ShimsContext.Create() Method

查看:13
本文介绍了无法运行使用 Microsoft Fakes 的单元测试 - ShimsContext.Create() 方法中的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题与此处报告的问题非常相似:UnitTestIsolationException 使用 Fakes 调试测试时

My problem is very similar to one reported here: UnitTestIsolationException when debugging tests using Fakes

但是,我什至无法运行测试.使用此处提供的示例代码:使用 Microsoft Fakes 隔离测试中的代码(Shim 入门),我在运行以下测试时遇到以下异常:

However, I am not even able to run the tests. Using the sample code provided here: Isolating Code Under Test with Microsoft Fakes (Getting Started with Shims), I get following exception on running the test below :

违规行是:

using (ShimsContext.Create())

运行测试异常:

测试名称:TestMethod1
测试全名:TestingShimsAndStubs.UnitTest1.TestMethod1
测试源:c:\poc\TestingShimsAndStubs\TestingShimsAndStubs\UnitTest1.cs:第12行
测试结果:失败
测试时长:0:00:00.0182403

Test Name: TestMethod1
Test FullName: TestingShimsAndStubs.UnitTest1.TestMethod1
Test Source: c:\poc\TestingShimsAndStubs\TestingShimsAndStubs\UnitTest1.cs : line 12
Test Outcome: Failed
Test Duration: 0:00:00.0182403

结果信息:

测试方法 TestingShimsAndStubs.UnitTest1.TestMethod1 抛出例外:Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException:无法获取分析器模块句柄 'C:\Program Files (x86)\Microsoft视觉工作室12.0\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\12.0.0\Microsoft.IntelliTrace.Profiler.12.0.0.dll'.找不到指定的模块 --->System.ComponentModel.Win32Exception: 指定的模块无法找到结果堆栈跟踪:在 Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.LibraryMethods.GetModuleHandle(String文档名称)在 Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.IntelliTraceInstrumentationProvider.LoadProfilerModule(字符串探查器路径)--- 内部异常堆栈跟踪结束 ---在 Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.IntelliTraceInstrumentationProvider.LoadProfilerModule(字符串探查器路径)在 Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.IntelliTraceInstrumentationProvider.Initialize()在 Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.InitializeUnitTestIsolationInstrumentationProvider()在 Microsoft.QualityTools.Testing.Fakes.Shims.ShimRuntime.CreateContext()在 Microsoft.QualityTools.Testing.Fakes.ShimsContext.Create()在 TestingShimsAndStubs.UnitTest1.TestMethod1() 在 c:\poc\TestingShimsAndStubs\TestingShimsAndStubs\UnitTest1.cs:line 16

Test method TestingShimsAndStubs.UnitTest1.TestMethod1 threw exception: Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException: Failed to get profiler module handle 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\12.0.0\Microsoft.IntelliTrace.Profiler.12.0.0.dll'. The specified module could not be found ---> System.ComponentModel.Win32Exception: The specified module could not be found Result StackTrace: at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.LibraryMethods.GetModuleHandle(String fileName) at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.IntelliTraceInstrumentationProvider.LoadProfilerModule(String profilerPath) --- End of inner exception stack trace --- at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.IntelliTraceInstrumentationProvider.LoadProfilerModule(String profilerPath) at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.IntelliTraceInstrumentationProvider.Initialize() at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.InitializeUnitTestIsolationInstrumentationProvider() at Microsoft.QualityTools.Testing.Fakes.Shims.ShimRuntime.CreateContext() at Microsoft.QualityTools.Testing.Fakes.ShimsContext.Create() at TestingShimsAndStubs.UnitTest1.TestMethod1() in c:\poc\TestingShimsAndStubs\TestingShimsAndStubs\UnitTest1.cs:line 16

我在我的机器上使用 Microsoft Visual Studio Ultimate 2013 Edition(版本 12.0.40629.00 Update 5)和 .Net Framework v 4.6.01055.还尝试在 Visual Studio 2015 企业版上运行测试

推荐答案

我不确定 VS2013/VS2015 发生了什么,但以管理员身份打开它(开始 -> 右键单击​​ Visual Studio 2013 -> 以管理员身份运行)然后打开测试项目似乎已经解决了这个问题!!!

Am not sure what VS2013/VS2015 was happening but opening it as an Administrator (Start -> Right Click Visual Studio 2013 -> Run As Administrator ) and then opening the Test project seems to have fixed the issue!!!

也许有一些公司政策阻止我的普通用户帐户无法访问该文件夹.模拟管理员帐户似乎已经解决了这个问题.非常感谢您修复它!

Maybe there is some Corporate Policy that is preventing my regular user account to not access the folder. Impersonating an admin account seems to have fixed the issue. Thanks a lot for fixing it!

在此处发帖后解决了无法运行使用 Microsoft Fakes 的单元测试 其中一位管理员修复了问题

The solution came after opening a post here Unable to run Unit Tests that uses Microsoft Fakes where one of the admins fixed the issue

这篇关于无法运行使用 Microsoft Fakes 的单元测试 - ShimsContext.Create() 方法中的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆