Unable to use Microsoft Fakes in VS2015 Enterprise - COR_PROFILER missing

风格不统一 提交于 2019-12-11 10:37:04

问题


I am attempting to use Microsoft Fakes in VS 2015 Enterprise. I have been unable to get any of the tests to even run.

I do not have a testsettings or runsettings file.

Simple test project has references to:

Microsoft.QualityTools.Testing.Fakes
Microsoft.VisualStudio.QualityTools.UnitTestFramework

Single class of the following:

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.QualityTools.Testing.Fakes;
namespace UnitTestProjectfortemp1
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            using (ShimsContext.Create()) { }
        }

        [TestMethod]
        public void TestMethod2()
        {

            using (ShimsContext.Create()) { Console.Write("test"); }
        }
    }
}

The error that happens for both tests:

Test Name:  TestMethod1
Test FullName:  UnitTestProjectfortemp1.UnitTest1.TestMethod1
Test Source:    C:\UnitTestProject1\UnitTestProject1\UnitTest1.cs : line 21
Test Outcome:   Failed
Test Duration:  0:00:00.0131326

Result StackTrace:  
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.IntelliTraceInstrumentationProvider.ResolveProfilerPath()
   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 UnitTestProjectfortemp1.UnitTest1.TestMethod1() in C:\UnitTestProject1\UnitTestProject1\UnitTest1.cs:line 23
Result Message: 
Test method UnitTestProjectfortemp1.UnitTest1.TestMethod1 threw exception: 
Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException: Failed to resolve profiler path from COR_PROFILER_PATH and COR_PROFILER environment variables.

I have tried various solutions such as Unable to Run Unit Tests that uses Microsoft Fakes - Exception in ShimsContext.Create(), but no luck.

EDIT: I tried running this from the console, but didn't include the output. Here is the output, it fails with VSTest

C:\UnitTestProject1\UnitTestProject1>vstest.console.exe bin\Debug\UnitTestProject1.dll
Microsoft (R) Test Execution Command Line Tool Version 14.0.25420.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
Failed   TestMethod1
Error Message:
   Test method UnitTestProjectfortemp1.UnitTest1.TestMethod1 threw exception:
Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException: Failed to resolve profiler path from COR_PROFILER_PATH and COR_PROFILER environment variables.
Stack Trace:
    at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.IntelliTraceInstrumentationProvider.ResolveProfilerPath()
   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 UnitTestProjectfortemp1.UnitTest1.TestMethod1() in C:\UnitTestProject1\UnitTestProject1\UnitTest1.cs:line 12

Failed   TestMethod2
Error Message:
   Test method UnitTestProjectfortemp1.UnitTest1.TestMethod2 threw exception:
Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException: Failed to resolve profiler path from COR_PROFILER_PATH and COR_PROFILER environment variables.
Stack Trace:
    at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.IntelliTraceInstrumentationProvider.ResolveProfilerPath()
   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 UnitTestProjectfortemp1.UnitTest1.TestMethod2() in C:\UnitTestProject1\UnitTestProject1\UnitTest1.cs:line 19

Total tests: 2. Passed: 0. Failed: 2. Skipped: 0.
Test Run Failed.
Test execution time: 0.2654 Seconds

Edit 2: Based on zaitsman's comment below, I tried to turn off the specific version for the Fakes reference.

Before it was:

    <ItemGroup>
        <Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"/>
    <Reference Include="System" />
  </ItemGroup>

After:

    <ItemGroup>
      <Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">

          <SpecificVersion>False</SpecificVersion>
     </Reference>
     <Reference Include="System" />
   </ItemGroup>

来源:https://stackoverflow.com/questions/44147376/unable-to-use-microsoft-fakes-in-vs2015-enterprise-cor-profiler-missing

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