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

dotnet test --list-tests command is not works as expected when using Microsoft.Testing.Platform mode #4401

Closed
filzrev opened this issue Dec 20, 2024 · 1 comment
Labels

Comments

@filzrev
Copy link

filzrev commented Dec 20, 2024

Describe the bug

When running tests with dotnet test - Microsoft.Testing.Platform mode
dotnet test --list-tests command is not works as expected.
It ignores --list-tests argument and run actual tests instead.

Steps To Reproduce

  1. Create test project with dotnet new mstest --sdk command
  2. Add code throw new Exception("UnitTest is Executed!"); to generated test code.
  3. Run dotnet test --list-tests command. And confirms list of tests are displayed.
  4. Modify generated csproj
    4.1, Remove <UseVSTest>true</UseVSTest> setting.
    4.2. Add following settings
    <TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
    <TestingPlatformCaptureOutput>false</TestingPlatformCaptureOutput>
    <TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
    
  5. Run dotnet test --list-tests command. And confirms actual tests are executed.

Expected behavior

List of tests are shown.

Actual behavior

--list-tests argument is ignored. And actual tests are executed.

Additional context

@Evangelink
Copy link
Member

Hi @filzrev,

Yes this is by design. dotnet test is made for VSTest and Microsoft.Testing.Platform is only trying to inject there so you cannot use arguments directly but needs to wrap them as documented here: https://learn.microsoft.com/dotnet/core/testing/unit-testing-platform-integration-dotnet-test#dotnet-test---microsofttestingplatform-mode.

Solution 1: dotnet test -- --list-tests
Solution 2: dotnet test -p:TestingPlatformCommandLineArguments="--list-tests"

We know this is not ideal but we weren't able to provide better with time constraints we were given. We are currently working on a revised dotnet test experience for MTP

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

No branches or pull requests

2 participants