-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Problem
The current dotnet test --list-tests command lists all tests in a project, but it does not respect filters (e.g., --filter Category=Integration). This makes it difficult to preview which tests would actually be selected before execution. Developers often need to validate filter expressions without running the tests.
Proposal
Enhance the existing --list-tests command with the following capabilities:
- Apply all existing filters (
--filter, runsettings, traits, etc.). - Output only the matching test cases.
- Support machine‑readable formats (e.g., JSON or XML) for CI/CD integration.
Example Usage
dotnet test --filter Category=Integration --list-tests --output-format json
Benefits
- Quickly validate filter expressions without executing tests.
- Save time in large test suites.
- Enable CI/CD workflows to check test selection logic programmatically.
- Provide consistent behavior with vstest.console.exe --list-tests, but integrated into dotnet test.
Use Case
In a CI/CD environment, I need to determine whether a given test assembly contains any tests that match the specified filters (e.g., --filter Category=Integration).
- If no tests match, the pipeline should skip executing that assembly, saving time and resources.
- If tests do match, the pipeline should forward the assembly for execution.
This requires a way to run dotnet test --list-tests with filters applied, producing a machine‑readable output that can be consumed by the CI/CD pipeline.