-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Option --list-tests should take into account --filter option #8643
Comments
Hi @evil-shrike thank you for the issue. You are correct, Hi @Faizan2304 is there any existing vstest API can do that? |
Unfortunately |
Hello, Any update on this issue ? BR, |
Seconded |
Same here, would be helpfull this issue to be landed... |
Definitely would be very useful for our team |
Useful for our team as well, any updates? |
I just ran into the same issue. If this could be updated, it would be very much appreciated. |
I actually want this for something other than verifying the correct tests have been selected by my filter, but this issue has forced me to use the NUnit console runner to get a list of test names for a given filter. |
Need that filter for list of tests too. |
I'd also appreciate this feature this isn't a complicated, unreal request - if you look and understand what all of us is trying to do, you'd know it's a very basic and practical use case So I'm struggling to understand why it wasn't implemented in this way from the start, but what I really don't understand is why the only response from the owners/devs was this -> "is not supported"... to me, that's sounds like the owners/devs/contributors are simply ignoring their community |
Yes, I really want this feature too, please! I assumed it was there but no :( it always lists ALL the tests. I have to actually run them to see which tests are under a give filter. @Riverlution thanks for the nunit idea! |
When I use it it tells me no test matches the filter. If I drop --list-tests it starts finding and running tests. |
[Previously](#6360), we split our `MSBuildIntegration` unit tests to run across multiple CI test agents. While a huge improvement, there are a few downsides to the approach we went with at the time: - The number of agents is hardcoded by copy/pasting steps in the CI YAML. - The tests must be manually load-balanced across agents with `[Category ("Node-X")]` in code which is cumbersome and hard to keep updated. As we are at the point where our tests have expanded well past the 1 hour target we are faced with needing to increase our parallelization. First, we can remove the YAML duplication by using AZDO's built-in `parallel` strategy, allowing us to control the number of agents to use with a single number: ```yaml - job: strategy: parallel: 4 ``` This leaves us the issue of automatically splitting our tests among an unknown number of test agents. A clever solution is [provided in the AZDO docs](https://learn.microsoft.com/en-us/azure/devops/pipelines/test/parallel-testing-any-test-runner?view=azure-devops): - Use `dotnet test --list-tests` to find all the tests - Use a script to calculate which tests the agent should run, based on `$(System.JobPositionInPhase)` and `$(System.TotalJobsInPhase)` - Pass those test names into `dotnet test` as a filter Unfortunately there are issues with the provided approach: - `dotnet test --list-tests` is not compatible with `--filter` so you have to run *all* tests in the test assembly which is not desirable for us. (dotnet/sdk#8643) - Passing test names (including test parameters) on the command line hits limitations with escaping certain characters and argument limits. So the approach is good, but we have to do all the work ourselves. Enter [dotnet-test-slicer](https://github.com/jpobst/dotnet-test-slicer). This dotnet global tool: - Uses the `NUnit.Engine` NuGet package to find all tests in a test assembly using the desired filter query. - Slices the test list for the current test agent. - Outputs the desired tests into an NUnit-specific `.runsettings` file that can be passed to `dotnet test --settings foo.runsettings`, bypassing command line arguments. Voila! Now we can automatically scale our test agents up or down as needed by changing a single variable in our YAML file. Limitation: The tests are sliced in a round robin fashion. This can produce uneven results if test durations are uneven. A future optimization would be to store approximate test durations so tests can be load balanced more intelligently.
Workaround for this case using
filters format for
And as a result, the |
It should throw if filter and list-tests are passed. |
Fixing this needs to be done in the respective repos of those (and other) test frameworks/test adapters. |
I'm trying to execute one particular test so I specify a filter, but
dotnet test
executes several tests. So I need to understand what tests my filter captures. I would expect that--list-tests
with--filter
tells me. But it doesn't.--list-tests
always shows all tests ignoring--filter
option which is a pity.Steps to reproduce
lists only tests satisfying the filter
Expected behavior
lists only tests satisfying the filter
Actual behavior
lists all tests in assembly
The text was updated successfully, but these errors were encountered: