-
Notifications
You must be signed in to change notification settings - Fork 325
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
Add test case filter based on existence of a property #1724
Comments
@tillig We haven't received any feedback for such a scenario before. I am just trying to understand more about the scenario we trying to enable. @pvlakshm @cltshivash Can you please triage this. |
My specific use case is that I have a microservice project that has a fully automated CI/CD pipeline. About half of the tests, spread across multiple assemblies, are unit tests. The other half, also spread across multiple assemblies, are BDD tests that run against the service during various stages of deployment. Right now, we have four types of tests:
The pipeline is evolving and more stages are being considered. As the service evolves and new unit test assemblies are added, it is easy for people to forget to add the Given the default type of test is effectively unit tests, we were hoping to be able to omit the trait entirely. The idea, then, being that a unit test is one that is not otherwise marked to be run in a particular stage of the deployment pipeline. Instead of this...
...we could do this:
Without that, as new stages get added (we're considering, for example, a stage called "Security") we then have to also update all the build scripts and filters:
Being able to test for empty/null would allow a default filter to work, no extra test markings (or things folks can easily forget), and no need to update the filter as the deployment stages/pipeline evolve. |
This is a new feature and won't be implemented, we are focusing on adding new features to Testing.Platform instead. https://aka.ms/testingplatform |
The documentation on TestCase filtering shows this example:
And it shows that you can run all the tests marked with
[TestCategory("CategoryA")]
using this command:dotnet test --filter TestCategory=CategoryA
However, if there doesn't seem to be a way to run tests that are not marked with any test category.
Same for XUnit:
I can run the test with a
Category=Nightly
... but I can't run choose to run tests with no Trait "Category".I've tried these and failed:
dotnet test --filter Category=''
dotnet test --filter Category=null
dotnet test --filter Category
dotnet test --filter !Category
dotnet test --filter Category!~''
(Some of these come up with
TestCaseFilter
errors where they aren't considered valid expressions.)My logic being the value of a non-existent property should be empty/null... but diving a little deeper into the filter code that doesn't seem to be the case. There doesn't seem to be a way to filter based on a property being/not being there.
I might propose one of the following solutions:
Category=''
would succeed.$null
value soCategory=$null
would succeed.!Category
would work.The text was updated successfully, but these errors were encountered: