Skip to content

MSTest v4 on .net6 fails test discovery with MissingMethodException - DoesReferencesAssembly #6809

@ehanover

Description

@ehanover

Describe the bug

I understand MSTest v4 drops official support for .NET 6, but I would like to try to work around this limitation because I must continue to support .NET 6. My solution builds but Test Discovery fails with MissingMethodException:

========== Starting test discovery ==========
Process: C:\...\TestProject\bin\x64\Debug\net6.0\TestProject1.dll, Exception: StreamJsonRpc.RemoteInvocationException: System.MissingMethodException: Method not found: 'System.Nullable`1<Boolean> Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities.AssemblyHelper.DoesReferencesAssembly(System.String, System.Reflection.AssemblyName)'.
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.TestSourceHandler.IsAssemblyReferenced(AssemblyName assemblyName, String source)
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Discovery.AssemblyEnumeratorWrapper.GetTests(String assemblyFileName, IRunSettings runSettings, ITestSourceHandler testSourceHandler, List`1& warnings) in /_/src/Adapter/MSTestAdapter.PlatformServices/Discovery/AssemblyEnumeratorWrapper.cs:line 42
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.UnitTestDiscoverer.DiscoverTestsInSource(String source, IMessageLogger logger, ITestCaseDiscoverySink discoverySink, IDiscoveryContext discoveryContext) in /_/src/Adapter/MSTestAdapter.PlatformServices/Discovery/UnitTestDiscoverer.cs:line 58
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.UnitTestDiscoverer.DiscoverTests(IEnumerable`1 sources, IMessageLogger logger, ITestCaseDiscoverySink discoverySink, IDiscoveryContext discoveryContext) in /_/src/Adapter/MSTestAdapter.PlatformServices/Discovery/UnitTestDiscoverer.cs:line 41
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.MSTestDiscoverer.DiscoverTests(IEnumerable`1 sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink, IConfiguration configuration) in /_/src/Adapter/MSTest.TestAdapter/VSTestAdapter/MSTestDiscoverer.cs:line 52
   at Microsoft.VisualStudio.TestTools.UnitTesting.MSTestBridgedTestFramework.SynchronizedDiscoverTestsAsync(VSTestDiscoverTestExecutionRequest request, IMessageBus messageBus, CancellationToken cancellationToken) in /_/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestBridgedTestFramework.cs:line 40
   at Microsoft.Testing.Extensions.VSTestBridge.SynchronizedSingleSessionVSTestBridgedTestFramework.<>c__DisplayClass22_0.<<ExecuteRequestAsync>b__0>d.MoveNext() in /_/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/SynchronizedSingleSessionVSTestAndTestAnywhereAdapter.cs:line 160
--- End of stack trace from previous location ---
...
========== Test discovery aborted: 0 Tests found in 418.8 ms ==========

Is there a way to resolve this issue so that the tests in .NET 6 are able to run? Or get closer to running? Thank you.

Steps To Reproduce

  1. Tested in Visual Studio 2022
  2. Project with <TargetFrameworks>net6.0;net8.0</TargetFrameworks> and <PackageReference Include="MSTest" Version="4.0.1" />
  3. Run tests
  4. Observe tests on net8.0 pass, while the test run on net6.0 fails during test discovery with the error above (in Tests output window) before executing

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: MSTestIssues with MSTest that are not specific to more refined area (e.g. analyzers or assertions)Resolution: By Design

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions