microsoft / testfx

MSTest framework and adapter
MIT License
723 stars 254 forks source link

Command Line Options - Set Defaults? e.g. minimum-expected-tests #3160

Closed thomhurst closed 3 months ago

thomhurst commented 3 months ago

The Microsoft.Testing.Platform hosts provides us a few bits out of the box, such as minimum-expected-tests.

Is there the ability for me within my framework to set a default value for a flag (that the user could then override?)

Currently, if I execute a test run that doesn't run any tests, the command doesn't return an error exit code. But I want to interpret that as "something went wrong".

I'd like to change this, so setting a default value of 1.

PS C:\git\TUnit\TUnit.TestProject> dotnet run --treenode-filter "/*/*/*/NonExistingTest"
.NET Testing Platform v1.3.0-preview.24321.4+a25e08a44c (UTC 06/21/2024 00:00:00) [win10-x64 - .NET 7.0.20]
Zero tests ran - Failed: 0, Passed: 0, Skipped: 0, Total: 0, Duration: 149ms - TUnit.TestProject.dll (win10-x64 - .NET 7.0.20)
Evangelink commented 3 months ago

Hi @tomhurst,

I am not sure to understand what you are saying.

By default, the platform expects to have at least 1 test run, failure to do so will result in exit code 8 (https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-platform-exit-codes) with the message Zero tests ran that you are seeing.

Do you mean you want to allow 0?

thomhurst commented 3 months ago

Ah sorry I could've sworn I printed out the exit code and it was 0. But it was actually 8. This is a non issue.

Evangelink commented 3 months ago

Glad to see there is no issue here.