Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mstest 3.4.1 does not discover a method from unit tests in visual studio when returning a Task with multiple frameworks #3033

Closed
fforjan opened this issue May 29, 2024 · 4 comments
Assignees
Milestone

Comments

@fforjan
Copy link

fforjan commented May 29, 2024

Describe the bug

mstest 3.4.1 does not discover a method from unit tests in visual when returning a Task with multiple frameworks

[Warning] [MSTest][Discovery][C:\Users\ISYS36005\source\repos\TestProject1\bin\Debug\net6.0-windows\TestProject1.dll] MSTestAdapter failed to discover tests in class 'TestProject1.UnitTest1' of assembly 'source\repos\TestProject1\bin\Debug\net6.0-windows\TestProject1.dll' because Method 'get_DataRow' 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..

Steps To Reproduce

Create a new unit tests project in a new solution with a method returning a task :
image
notice that the frameworks targets both net472 and net6.0-windows

Expected behavior

Both tests in both framework should be discovered and be able to execute

Actual behavior

net6.0-windows is not discovered

Additional context

Tested in Visual Studio 2022 17.10.0

@fforjan fforjan changed the title mstest 3.4.1 does not discover a method from unit tests in visual when returning a Task with multiple frameworks mstest 3.4.1 does not discover a method from unit tests in visual studio when returning a Task with multiple frameworks May 29, 2024
@Evangelink
Copy link
Member

Cannot repro the issue in VS nor CLI using vstest.console.exe or dotnet test

Repro project:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>net472;net6.0-windows</TargetFrameworks>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <LangVersion>12</LangVersion>
    <IsPackable>false</IsPackable>
    <IsTestProject>true</IsTestProject>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="MSTest" Version="3.4.1" />
    <PackageReference Include="coverlet.collector" Version="6.0.0" />
  </ItemGroup>
  
  <ItemGroup>
	<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
  </ItemGroup>

</Project>

test class

namespace TestProject2
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public Task TestMethod2()
        {
            return Task.CompletedTask;
        }
    }
}

@fforjan
Copy link
Author

fforjan commented May 29, 2024

ok, recipe update.

@fforjan
Copy link
Author

fforjan commented May 29, 2024

and from that stage onwards, if the test method is back to a void, it is discovered, if it move back to a Task, it cannot be discovered !

@Evangelink Evangelink added this to the 3.4.2 milestone May 29, 2024
@Evangelink
Copy link
Member

Fixed by #3034

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants