Skip to content

[Feature]: I need a way to control the exit code of dotnet test for skipped tests #4102

@pnquest

Description

@pnquest

Problem Statement

I am looking into migrating from XUnit, and am running into an issue in CI. I have a solution with multiple test projects. Most of the test projects are unit tests, but there is one project that is all Integration tests, which are marked with the Category Integration.

In CI, which is used for multiple different repositories, we run the unit tests in one pipeline job, and the integration tests in another by just running dotnet test against the solution file. I accomplish this today using --filter Category=Integration for the integration job, and the inverse of this for the unit test job. I see that I can do the same thing with --treenode-filter, and it works, except that when the filter causes all the tests in a project to be skipped, the exit code is 1, which causes my CI to fail.

Proposed Solution

I assume this was done to help catch someone accidentally skipping all tests, but for my use case, I would like some way to override this behavior, and make it work like XUnit did. 2 Options come to mind:

  1. A new flag that disables this behavior
  2. A different exit code when there are no tests failing but an entire project was skilled. Then I could use your existing --ignore-exit-code flag to ignore that exit code for my use case.

Alternatives Considered

No response

Feature Category

Test Execution / Lifecycle

How important is this feature to you?

Critical - blocking my adoption/usage of TUnit

Additional Context

No response

Contribution

  • I'm willing to submit a pull request for this feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions