I am having some problems after enabling Code Coverage during our TFS builds. The solution under test contain three test projects and out of 209 tests three tests fail (one in one project and two in another), with the following error:
Test method MyNamespace.MyTest threw exception:
Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException: Unexpected error returned by SetDetourProvider in profiler library 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\14.0.0\Microsoft.IntelliTrace.Profiler.14.0.0.dll'.
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()
MyNamespace.MyTest () in MyFile.cs: line 224
The stack trace indicates that is connected to the use of Shims. All test pass locally even when running Code Coverage and disabling Code Coverage during build makes the tests pass again. The issue seems slightly related to Microsoft Fakes generates UnitTestIsolationException, but Resharper is not installed on the build servers.
What I have tried:
- Different build types: Build vNext, XAML Build with customized or Default Template
- Explicitly disabled IntelliTrace using
/p:EnableIntelliTrace=true
and .runsetting - Added
Diagnostic="true"
to all .fakes files - Increased Logging Verbosity to get more error information
- Run the tests locally on the server through command line
My build server setup:
- Windows Server 2012 R2
- Team Foundation Server 2015.3
- Visual Studio Enterprise 2015.3