Skip to content

MTP treats test run as failed if all tests are skipped #5186

Closed as not planned

Description

Describe the bug

If every test in a test project is dynamically skipped, Microsoft Testing Platform will report the tests as failed, causing the build to fail.

The scenario here is that my end-to-end tests are only run as part of deployment and are conditioned to check for some environment variables and AWS credentials, and skip if they aren't present. This makes it easy to just run dotnet test and validate in CI that the test project is building/working, rather than having to duplicate the conditional logic to not run the specific test project at all.

Steps To Reproduce

  1. Clone martincostello/alexa-london-travel@c766543
  2. Run dotnet test (or build.ps1) from the root of the repository

Expected behavior

All tests are successful.

Actual behavior

❯ .\build.ps1
Publishing solution...
Restore complete (1.8s)
  LondonTravel.Skill succeeded (103.7s) → artifacts\publish\LondonTravel.Skill\release\

Build succeeded in 106.4s
Testing 3 project(s)...
Restore complete (1.0s)
  LondonTravel.Skill succeeded (0.6s) → artifacts\bin\LondonTravel.Skill\release\LondonTravel.Skill.dll
  LondonTravel.Skill.Tests succeeded (2.3s) → artifacts\bin\LondonTravel.Skill.Tests\release\LondonTravel.Skill.Tests.dll
  LondonTravel.Skill.Tests test succeeded (11.3s)

Test summary: total: 104, failed: 0, succeeded: 104, skipped: 0, duration: 11.2s
Build succeeded in 15.9s
Restore complete (0.8s)
  LondonTravel.Skill succeeded (2.1s) → artifacts\bin\LondonTravel.Skill\debug\LondonTravel.Skill.dll
  LondonTravel.Skill.AppHost succeeded (1.8s) → artifacts\bin\LondonTravel.Skill.AppHost\debug\LondonTravel.Skill.AppHost.dll
  LondonTravel.Skill.AppHostTests succeeded (1.7s) → artifacts\bin\LondonTravel.Skill.AppHostTests\debug\LondonTravel.Skill.AppHostTests.dll
  LondonTravel.Skill.AppHostTests test succeeded (48.5s)

Test summary: total: 9, failed: 0, succeeded: 9, skipped: 0, duration: 48.4s
Build succeeded in 56.2s
Restore complete (0.5s)
  LondonTravel.Skill.EndToEndTests succeeded (3.1s) → artifacts\bin\LondonTravel.Skill.EndToEndTests\release\LondonTravel.Skill.EndToEndTests.dll
  LondonTravel.Skill.EndToEndTests test failed with 1 error(s) (4.1s)
    C:\Coding\martincostello\alexa-london-travel\artifacts\bin\LondonTravel.Skill.EndToEndTests\release\LondonTravel.Skill.EndToEndTests.dll : error run failed: Tests failed: 'C:\Coding\martincostello\alexa-london-travel\artifacts\bin\LondonTravel.Skill.EndToEndTests\release\TestResults\LondonTravel.Skill.EndToEndTests_net9.0_x64.log' [net9.0|x64]

Test summary: total: 13, failed: 0, succeeded: 0, skipped: 13, duration: 4.0s
Build failed with 1 error(s) in 8.6s
Exception: C:\Coding\martincostello\alexa-london-travel\build.ps1:93
Line |
  93 |          throw "dotnet test failed with exit code $LASTEXITCODE"
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | dotnet test failed with exit code 1
Test log
xUnit.net v3 Microsoft.Testing.Platform Runner v2.0.0+229879b765 (64-bit .NET 9.0.2)

skipped Can_Invoke_Skill_And_Get_Valid_Response(content: "Alexa, ask London Travel about the Victoria line.") (0ms)
  No Lambda function name is configured.
skipped Can_Invoke_Skill_And_Get_Valid_Response(content: "Alexa, ask London Travel about the Windrush line.") (0ms)
  No Lambda function name is configured.
skipped Can_Invoke_Skill_And_Get_Valid_Response(content: "Alexa, ask London Travel about the DLR.") (0ms)
  No Lambda function name is configured.
skipped Can_Invoke_Skill_And_Get_Valid_Response(content: "Alexa, ask London Travel about the Elizabeth line.") (0ms)
  No Lambda function name is configured.
skipped Can_Invoke_Skill_And_Get_Valid_Response(content: "Alexa, ask London Travel if there is any disruptio"···) (0ms)
  No Lambda function name is configured.
skipped Can_Invoke_Intent_Can_Get_Json_Response(payloadName: "Disruption") (0ms)
  No AWS credentials are configured.
skipped Can_Invoke_Intent_Can_Get_Json_Response(payloadName: "Stop") (0ms)
  No AWS credentials are configured.
skipped Can_Invoke_Intent_Can_Get_Json_Response(payloadName: "Cancel") (0ms)
  No AWS credentials are configured.
skipped Can_Invoke_Intent_Can_Get_Json_Response(payloadName: "Help") (0ms)
  No AWS credentials are configured.
skipped Can_Invoke_Intent_Can_Get_Json_Response(payloadName: "UnknownIntent") (0ms)
  No AWS credentials are configured.
skipped Can_Invoke_Intent_Can_Get_Json_Response(payloadName: "Status") (0ms)
  No AWS credentials are configured.
skipped Can_Invoke_Intent_Can_Get_Json_Response(payloadName: "Launch") (0ms)
  No AWS credentials are configured.
skipped Can_Invoke_Intent_Can_Get_Json_Response(payloadName: "SessionEnded") (0ms)
  No AWS credentials are configured.

Test run summary: Zero tests ran - C:\Coding\martincostello\alexa-london-travel\artifacts\bin\LondonTravel.Skill.EndToEndTests\debug\LondonTravel.Skill.EndToEndTests.dll (net9.0|x64)
  total: 13
  failed: 0
  succeeded: 0
  skipped: 13
  duration: 723ms

=== COMMAND LINE ===
C:\Program Files\dotnet\dotnet.exe exec C:\Coding\martincostello\alexa-london-travel\artifacts\bin\LondonTravel.Skill.EndToEndTests\debug\LondonTravel.Skill.EndToEndTests.dll --internal-msbuild-node testingplatform.pipe.80f329cfebcb46d4b7b6adcbe1f4dd0f 



Additional context

Similar issue to dotnet/sdk#39665 regarding how skipped tests are treated.

Activity

  1. Youssef1313 commented on Mar 7, 2025

    @Youssef1313
    Member

    This was an intentional decision. You can add <TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --ignore-exit-code 8</TestingPlatformCommandLineArguments> in your project file under a PropertyGroup to ignore the "zero tests ran" exit code.

  2. added
    resolution/by-design
    needs/author-feedback
    area/mtp
    and removed
    needs/triage
    on Mar 7, 2025
  3. Evangelink commented on Mar 7, 2025

    @Evangelink
    Member

    Martin Costello (@martincostello) Just adding some more context here. With VSTest, we noticed many cases of people not noticing that no tests were run because of a bad configuration. With MTP, we are are trying to have stricter defaults so we can avoid all the easy/silly mistakes

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/mtpresolution/by-design

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions