Visual Studio 2019 xUnit/MsTests Fakes Crashes

406 views Asked by At

Simple Unit Test in xUnit and MSTests crashes with the message below:

  • Microsoft.QualityTools.Testing.Fakes (v16.7.4-beta)
  • dotnet core 3.1
  • Using Visual Studio Enterprise 2019 IDE to run this test.

Any idea how to get this working ?

 public class UnitTest1
 {
    [Fact]
    public void Test1()
    {
        int fixedYear = 2000;

        // Shims can be used only in a ShimsContext:
        using (ShimsContext.Create())
        {
            
        }

    }
}

Error Message:

XUnitTestProject1.UnitTest1.Test1
   Source: UnitTest1.cs line 10
   Duration: 24 ms

  Message: 
    Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException : Unexpected error returned by SetDetourProvider in profiler library 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\TestPlatform\Extensions\Fakes\x64\Microsoft.QualityTools.Testing.Fakes.Instrumentation.dll'.
  Stack Trace: 
    IntelliTraceInstrumentationProvider.Initialize()
    UnitTestIsolationRuntime.InitializeUnitTestIsolationInstrumentationProvider()
    ShimRuntime.CreateContext()
    ShimsContext.Create()
    UnitTest1.Test1() line 15
1

There are 1 answers

0
Lydon Ch On

This is resolved using NUnitTestProject as NUnit is not using coverlet.collector ( a guess from looking at error message and project dependencies)

Both xUnit and MSTestUnit are using coverlet.collector, and both crashes.