You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Command line option minimum-expected-tests does not accept 0 #3121
There is definitely something wrong. I am not sure to understand the use case where you would want to run no test, it would seem like a bug to me.
Hi,
we use normally --filter to remove integration tests. With old MSTest works without problem.
In our case it is "dotnet test solution.sln with -p:TestingPlatformCommandLineArguments" like here #2175
MSTest Runner throws error because integration tests report 0 tests. Actually --filter should ignore them completely?
MSTest Runner throws error because integration tests report 0 tests. Actually --filter should ignore them completely?
I am not sure to understand what you mean. With the runner (compared to VSTest) we have made the choice to be strict by default and we do consider running no test as an abnormal situation (this was a recurring complaint in VSTest). If you think this is fine for your situation to request test execution of zero tests, then you should use the --ignore-exit-code.
MSTest Runner throws error because integration tests report 0 tests. Actually --filter should ignore them completely?
I am not sure to understand what you mean. With the runner (compared to VSTest) we have made the choice to be strict by default and we do consider running no test as an abnormal situation (this was a recurring complaint in VSTest). If you think this is fine for your situation to request test execution of zero tests, then you should use the --ignore-exit-code.
Let me know if I am missing something.
Thanks for quick answer.
Example:
Solution has 10 test projects. One of the projects is integration tests project.
We want to run only unit tests projects with "dotnet test Solution.sln..." So we use --filter parameter to filter integration tests projects out.
Short story:
Step 1: Run unit tests from solution
Step 2: Run integration tests from solution later in the build pipeline
We have been discussing internally and we don't think it's interesting to support passing 0 to this parameter. We prefer users to keep ignoring the exit code 8
And what about --filter option? Does it work as designed, that actually whole namespace(Project) is filtered out, but it shows up in the logs and here we have an exit code 8?
And what about --filter option? Does it work as designed, that actually whole namespace(Project) is filtered out, but it shows up in the logs and here we have an exit code 8?
Ah right! That's because our new platform (MSTest runner) works on exe level so for this test application instance no test was executed. I am more thorned about this case but I think it boils down to the same reasoning.
Dimitri Kroo (@SymbioticKilla) For now you will have to stick with the --ignore-exit-code 8 but I think it would be useful to be able to have this setting working at group of projects level instead so I have created a new ticket for that.
I'll move forward by closing this one as the blogpost was updated.
I have a similar scenario to Dimitri Kroo (@SymbioticKilla). We run a mono repo, so run tests for an app against a slnf set up for that app (containing all its dependencies and their test projects).
My preference would obv be to always ensure there's a test that will run, so we can have a minimum. This is easy enough when you're doing a filter for non-integration tests, as it's usually possible to do a pretty basic unit test in every test project. But, that's not really possible on the inverse run like dotnet test MyCompany.MyApp1.slnf -- --filter-query "/[TestType=Integration]", which will iterate over test projects for shared/util libraries which, more often than not, won't have integration tests.
I can't really see a way around this without ignoring the exit code at this stage, and taking on the risk someone renames test traits or something and we don't run anything. Tricky situation.
Edit: If I think about what the Test Explorer does, I guess because it filters out projects that don't match the filter, it doesn't run any that aren't needed and all is fine. Not sure that's really applicable here though.
Not connected directly to MTP, but for the case when you would not run anything it is probably best to get a build server support that allows you to say: Fail test run if it has 10% less tests than last successful run on main.
Activity
Evangelink commentedon Jun 18, 2024
There is definitely something wrong. I am not sure to understand the use case where you would want to run no test, it would seem like a bug to me.
MarcoRossignoli commentedon Jun 18, 2024
This is correct.
I think we there's a bug in the documentation. Run 0 tests is unexpected so imo doesn't make a lot of sense have the idea of "minimum" on 0 quantity.
janis938 commentedon Jun 18, 2024
Thank you!
SymbioticKilla commentedon Jun 18, 2024
Hi,
we use normally --filter to remove integration tests. With old MSTest works without problem.
In our case it is "dotnet test solution.sln with -p:TestingPlatformCommandLineArguments" like here #2175
MSTest Runner throws error because integration tests report 0 tests. Actually --filter should ignore them completely?
Evangelink commentedon Jun 18, 2024
I am not sure to understand what you mean. With the runner (compared to VSTest) we have made the choice to be strict by default and we do consider running no test as an abnormal situation (this was a recurring complaint in VSTest). If you think this is fine for your situation to request test execution of zero tests, then you should use the
--ignore-exit-code.Let me know if I am missing something.
SymbioticKilla commentedon Jun 18, 2024
Thanks for quick answer.
Example:
Solution has 10 test projects. One of the projects is integration tests project.
We want to run only unit tests projects with "dotnet test Solution.sln..." So we use --filter parameter to filter integration tests projects out.
Short story:
Step 1: Run unit tests from solution
Step 2: Run integration tests from solution later in the build pipeline
SymbioticKilla commentedon Jun 28, 2024
Hey! Do you need more information or solution example?
Evangelink commentedon Jun 28, 2024
Hi Dimitri Kroo (@SymbioticKilla),
Sorry!!! It's clear for us!
We have been discussing internally and we don't think it's interesting to support passing
0to this parameter. We prefer users to keep ignoring the exit code 8SymbioticKilla commentedon Jun 28, 2024
Hi Amaury Levé (@Evangelink) ,
thanks! Seems legit.
And what about --filter option? Does it work as designed, that actually whole namespace(Project) is filtered out, but it shows up in the logs and here we have an exit code 8?
Evangelink commentedon Jul 2, 2024
Blogpost was fixed.
Do you have a reproducer for this case? It's not entirely clear to me what you mean. Here is the doc about how to filter https://learn.microsoft.com/dotnet/core/testing/selective-unit-tests?pivots=mstest#mstest-examples
SymbioticKilla commentedon Jul 2, 2024
TestProjectFilter.zip
As you can see, it is not possible to filter out the whole project without adding
--ignore-exit-code 8Evangelink commentedon Jul 2, 2024
Ah right! That's because our new platform (MSTest runner) works on exe level so for this test application instance no test was executed. I am more thorned about this case but I think it boils down to the same reasoning.
cc Marco Rossignoli (@MarcoRossignoli)
Evangelink commentedon Jul 4, 2024
Dimitri Kroo (@SymbioticKilla) For now you will have to stick with the
--ignore-exit-code 8but I think it would be useful to be able to have this setting working at group of projects level instead so I have created a new ticket for that.I'll move forward by closing this one as the blogpost was updated.
benmccallum commentedon Mar 21, 2025
I have a similar scenario to Dimitri Kroo (@SymbioticKilla). We run a mono repo, so run tests for an app against a slnf set up for that app (containing all its dependencies and their test projects).
My preference would obv be to always ensure there's a test that will run, so we can have a minimum. This is easy enough when you're doing a filter for non-integration tests, as it's usually possible to do a pretty basic unit test in every test project. But, that's not really possible on the inverse run like
dotnet test MyCompany.MyApp1.slnf -- --filter-query "/[TestType=Integration]", which will iterate over test projects for shared/util libraries which, more often than not, won't have integration tests.I can't really see a way around this without ignoring the exit code at this stage, and taking on the risk someone renames test traits or something and we don't run anything. Tricky situation.
Edit: If I think about what the Test Explorer does, I guess because it filters out projects that don't match the filter, it doesn't run any that aren't needed and all is fine. Not sure that's really applicable here though.
nohwnd commentedon Mar 21, 2025
Not connected directly to MTP, but for the case when you would not run anything it is probably best to get a build server support that allows you to say: Fail test run if it has 10% less tests than last successful run on main.
SymbioticKilla commentedon Mar 21, 2025
Hi Ben McCallum (@benmccallum),
we use code coverage check for this purpose.
Broken(flaky etc.), commented, deleted or not runned test is always a risk.