testfx icon indicating copy to clipboard operation
testfx copied to clipboard

`DynamicData` in vscode test explorer are split

Open nohwnd opened this issue 11 months ago • 2 comments

I also have a issue with DynamicData in vscode test explorer. same cause here?

image

Originally posted by @xcaptain in https://github.com/microsoft/testfx/issues/2237#issuecomment-1963996602

nohwnd avatar Feb 27 '24 08:02 nohwnd

Moved your issue here @xcaptain, the other issue was a work item to create an analyzer, and not an issue report.

Are you using mstest runner (MSTest 3.2.0+ with EnableMSTestRunner) to run your tests in vscode? Or the standard mstest?

@drognanar could you help here please?

nohwnd avatar Feb 27 '24 08:02 nohwnd

Yes, I'm using MSTest: 3.2.1, below are my test project 's config

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

  <PropertyGroup>
    <!-- Enable the MSTest runner, this is an opt-in feature -->
    <EnableMSTestRunner>true</EnableMSTestRunner>
    <OutputType>Exe</OutputType>

    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>

    <IsPackable>false</IsPackable>
    <IsTestProject>true</IsTestProject>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="MSTest" Version="3.2.1" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\CsPractice\CsPractice.csproj" />
  </ItemGroup>

</Project>

xcaptain avatar Feb 27 '24 10:02 xcaptain

The return type is expected to be IEnumerable<object[]> or IEnumerable<(Value)Tuple>, yours is IEnumerable<int[][]> so I think this is messing up the display. There's definitely something that should be fixed on MSTest side for this case.

I haven't investigated so I am not sure if we should just consider this case invalid or consider that the 2 level of array is the value of each "item".

We should test if the display is different between VS and VS Code, if that's the case then there is a bug in Test Explorer too.

cc @MarcoRossignoli

Evangelink avatar Mar 02 '24 09:03 Evangelink

Tests display in vs2022 is good

image

xcaptain avatar Mar 03 '24 11:03 xcaptain

@drognanar could you please investigate?

Evangelink avatar Mar 06 '24 13:03 Evangelink

@xcaptain, what version of vscode dev kit are you using?

I'm currently cannot reproduce this issue:

image

drognanar avatar Mar 06 '24 14:03 drognanar

I was using the C# devkit preview version got the above splitted rows. But now I tried switch to the release version, the test explore shows nothing. image

In vscode C# devkit test explorer output, I found these logs

Initialized project system provider.
1 projects added, 0 changed, 0 removed.
Scheduling discovery: /home/joey/github/demo1/artifacts/bin/CsPractice.Tests/debug/CsPractice.Tests.dll [1709739288831]
========== 正在启用测试发现 ==========
System.ComponentModel.Win32Exception (2): An error occurred trying to start process '/home/joey/github/demo1/artifacts/bin/CsPractice.Tests/debug/CsPractice.Tests.exe' with working directory '/home/joey/github/demo1/artifacts/bin/CsPractice.Tests/debug'. No such file or directory
   at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at Microsoft.VisualStudio.TestWindow.Internal.RemoteAgent.TestingPlatform.TestingPlatformRunnerProcess.StartAsync()
   at Microsoft.VisualStudio.TestWindow.Internal.RemoteAgent.TestingPlatform.Providers.ClientServerProvider.StartProcessWithoutDebuggerAsync(TestingPlatformLaunchConfig config)
无法启动测试平台运行器进程“/home/joey/github/demo1/artifacts/bin/CsPractice.Tests/debug/CsPractice.Tests.exe”。
========== 测试发现已中止: 69.1 毫秒 中发现 0 个测试 ==========
0 tests discovered from  in 69.1156 ms

But in my artifacts directory, there is no CsPractice.Tests.exe file, I'm using wsl. image

So according to my rough thinking, I think there exists 2 problems:

  1. vscode C# dev kit (preview) is not compatible with the new MSTest runner, causing splitted display
  2. vscode C# devkit (release) can't detect the real exe file for the test project

xcaptain avatar Mar 06 '24 15:03 xcaptain

I then copied my test project to windows, and vscode test explorer is good in windows. image

The C# devkit test explorer log is also good:

3 tests discovered from C:\Users\capta\Downloads\demo1\artifacts\bin\CsPractice.Tests\debug\CsPractice.Tests.dll in 8754.412 ms

So the problem should be vscode C# devkit test explorer is not displaying well on wsl.

Sorry for your time.

xcaptain avatar Mar 06 '24 16:03 xcaptain

if you create a .vscode/settings.json you can add the following setting:

{
    "dotnet.testWindow.useTestingPlatformProtocol": false
}

we've fixed the wsl support, but that hasn't been released yet. with this setting DevKit should fallback on an older way that we used to run tests until the bug fix is released.

drognanar avatar Mar 06 '24 17:03 drognanar

@xcaptain can you try it with the latest version of DevKit? I don't see any issues with the tree anymore and the code works both with the protocol setting enabled and disabled

drognanar avatar Mar 18 '24 20:03 drognanar

C# devkit(preview) in wsl is good for me now, I think it's ok to close this issue, thanks you for the help.

xcaptain avatar Mar 19 '24 02:03 xcaptain