Felipe Rodrigues
Felipe Rodrigues

Reputation: 33

Unit Tests that use ShimContext.Create() getting error on Azure DevOps Pipeline

I have some unit tests that use Fakes and ShimContext. When they run on the Visual Studio Enterprise 2017 IDE they run successfully, however, when the unit tests are run on the pipeline they are throwing the following error:

Error Message:

Test method MyTestMehodName threw exception: Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException: Unexpected error returned by SetDetourProvider in profiler library 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\Microsoft.IntelliTrace.Profiler.dll'.

Stack Trace:

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 MySolutuionPath.MyTestMehodName() in \ProjectTestName\TestFileName.cs:line 115

I am able to reproduce this error on the Visual Studio IDE when I add anew TestSetting file to the solution and enable IntelliTrace option: Adding Test setting file to solution

Configuration of the build server:

This is my test method

[TestMethod]
public void MyTestMethodName()
{
      using (ShimsContext.Create())
      {
          // Unit Test goes here with Assert
      }
}

This is how pipeline looks like: Pipeline This is the YAML configuration

steps:
 - task: VSTest@2
  displayName: 'Run Unit Tests'
  inputs:
    testAssemblyVer2: |
     **\*test*.dll
     !**\*TestAdapter.dll
     !**\obj\**
     !**\*QualityTools.UnitTestFramework.dll
     !**\*QualityTools.Testing.Fakes.dll
    searchFolder: '$(Build.BinariesDirectory)'
    vsTestVersion: toolsInstaller
    runInParallel: true
    runTestsInIsolation: false
    codeCoverageEnabled: false
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'
  continueOnError: true

Solutions I have tried:

I was wondering whether I was missing any installation on the build server. However, if the unit test run successfully inside the the IDE (Test Explorer) I assumed that I have anything missing.

Upvotes: 3

Views: 1145

Answers (1)

Everton Santos
Everton Santos

Reputation: 162

According to this stack overflow post you could try to change your build agent service to logon as a Normal Privilege User, instead of system/local user.

Upvotes: 0

Related Questions