testfx icon indicating copy to clipboard operation
testfx copied to clipboard

MSTest.TestAdapter > 2.2.8 "MSTestAdapter failed to discover tests in class" in Net 6.0 test project

Open wangyuan8421 opened this issue 3 years ago • 3 comments

The most useful log message "Method 'get_Properties' in type 'Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.TestContextImplementation' from assembly 'Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' does not have an implementation"

Description

We have a MSTest project target to Net 6.0 (windows 11, most updated Visual Studio 2022). Use VS project wizard create the MSTest project, it will install "MSTest.TestAdapter 2.2.8" by default. And everything works fine.

If we upgrade "MSTest.TestAdapter > 2.2.8", the VS test explorer will throw warning "MSTestAdapter failed to discover tests in class"

Steps to reproduce

  • Windows 11, most updated Visual Studio 2022, create a MSTEST project in Net 6.0

  • It will install ["MSTest.TestAdapter", "MSTest.TestFramework"] version 2.2.8 by default

  • The unit test will run and test without problem image

  • Then, I upgrade the ["MSTest.TestAdapter", "MSTest.TestFramework"] >= 2.2.10

  • The Visual Studio test explorer will not find any unit test from dll image

  • Test explorer warning image

  • Warning message detail (hide some directory / class name) image

Expected behavior

Nuget > 2.2.8 should find test case in dll.

Actual behavior

Nuget > 2.2.8 (v2.3.0-preview-20220810-02 has same issue) cannot find test case in dll.

Environment

Please share additional details about the test environment.

  • Operating system: Windows 11
  • Build version of vstest.console: Microsoft (R) Test Execution Command Line Tool Version 17.3.0-preview-20220626-01 (x64)
  • Package version of MSTest framework and adapter: 2.2.8 is working, 2.2.10 and 2.3.0-preview-20220810-02 does not working. Didn't test before 2.2.8
  • Other installed packages and their versions on the test project: <PackageReference Include="Microsoft.VisualStudio.TestPlatform" Version="14.0.0.1" />

wangyuan8421 avatar Sep 15 '22 15:09 wangyuan8421

Thanks for reporting this issue! Would you have any demo/repro case we could use to debug?

Evangelink avatar Sep 15 '22 15:09 Evangelink

@Evangelink I just create this simple demo project. https://github.com/wangyuan8421/MsTestAdapterBugDemo/tree/main/MsTestAdapterBugDemo

Also I did some investigation and I found something new.

Microsoft.VisualStudio.TestPlatform play an important role here

This combination works: image

This combination does not working: image

Hope this will help.

wangyuan8421 avatar Sep 15 '22 15:09 wangyuan8421

You don't need and probably shouldn't be installing Microsoft.VisualStudio.TestPlatform, the right dependency is already provided by using Microsoft.NET.Test.Sdk.

Evangelink avatar Sep 15 '22 16:09 Evangelink

Hi @wangyuan8421, sorry for the delay in answering your request! I have created a PR (https://github.com/wangyuan8421/MsTestAdapterBugDemo/pull/1/files) against your demo repository where I simply removed the references to Microsoft.VisualStudio.TestPlatform and now the tests are correctly discovered/executed:

image

I will move forward by closing this issue but please feel free to let us know if you are still facing the issue.

Evangelink avatar Sep 27 '22 08:09 Evangelink