mstest 3.4.1 does not discover a method from unit tests in visual studio when returning a Task with multiple frameworks
fforjan opened this issue · comments
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 :
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
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;
}
}
}
ok, recipe update.
- you have everything working.
add the [DeploymentItem("Foo")] on the test itself - build, run the test
the test cannot be discovered in net6 - that's issue #3019 - remove the [DeploymentItem] attribute & build
- the test disappears
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 !
Fixed by #3034