Unable to run Unit Tests that uses Microsoft Fakes - Exception in ShimsContext.Create() Method

梦想与她 提交于 2019-12-06 14:37:51

问题


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

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 :

the offending line is :

using (ShimsContext.Create())

Exception on running the test:

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

Result Message:

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

I am using Microsoft Visual Studio Ultimate 2013 Edition (Version 12.0.40629.00 Update 5) with .Net Framework v 4.6.01055 on my machine. Also tried running the tests on Visual Studio 2015 Enterprise Edition as well


回答1:


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!

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



来源:https://stackoverflow.com/questions/36464676/unable-to-run-unit-tests-that-uses-microsoft-fakes-exception-in-shimscontext-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!