-
Notifications
You must be signed in to change notification settings - Fork 289
Add support for filtering uncategorized tests with empty TestCategory filter #6779
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: nohwnd <[email protected]>
src/Platform/Microsoft.Testing.Extensions.VSTestBridge/ObjectModel/Condition.cs
Show resolved
Hide resolved
.../UnitTests/Microsoft.Testing.Extensions.VSTestBridge.UnitTests/ObjectModel/ConditionTests.cs
Outdated
Show resolved
Hide resolved
…rtions Co-authored-by: Evangelink <[email protected]>
src/Platform/Microsoft.Testing.Extensions.VSTestBridge/ObjectModel/FastFilter.cs
Outdated
Show resolved
Hide resolved
src/Platform/Microsoft.Testing.Extensions.VSTestBridge/ObjectModel/FastFilter.cs
Show resolved
Hide resolved
| TestCategories = categories; | ||
| // Treat empty or whitespace-only strings as null/uncategorized | ||
| // This ensures empty categories are not added to the list | ||
| if (string.IsNullOrWhiteSpace(testCategory)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make sure to have consistent behavior in TestCategoryBaseAttribute as well.
Or instead of simply ignoring null/empty/whitespace, it should be a clear error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current implementation treats empty/null/whitespace as uncategorized in TestCategoryAttribute. Since TestCategoryBaseAttribute is abstract and used for custom implementations, the validation is in the concrete TestCategoryAttribute class. Users creating custom category attributes can implement their own validation logic in their derived classes. Would you prefer we throw an ArgumentException for empty/null/whitespace instead of silently treating them as uncategorized?
| Guard.NotNull(propertyValueProvider); | ||
|
|
||
| bool matched = false; | ||
| foreach (string name in FilterProperties.Keys) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this whole implementation is a copy from vstest.
- Is there no public API from VSTest that we can call here?
- I think we should get those changes first in vstest repo, test it there, and then replicate here in testfx.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're correct that this is copied from vstest. The VSTestBridge component is designed to provide compatibility with vstest behavior in the new Microsoft.Testing.Platform. The note at the top of these files states "This file is copied as-is from VSTest source code."
For this feature, we're implementing it here first as part of the new testing platform. If the team prefers to implement it in vstest first and then port it here, I can hold off on these changes. What's the preferred approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation also seems like a copy from vstest. I'd like to fix it in vstest first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as with FastFilter - this is copied from vstest as noted in the file header. Should we prioritize implementing this in vstest first, or is it acceptable to implement here in the VSTestBridge for the new platform and potentially backport later?
src/Platform/Microsoft.Testing.Extensions.VSTestBridge/ObjectModel/Condition.cs
Show resolved
Hide resolved
src/Platform/Microsoft.Testing.Extensions.VSTestBridge/ObjectModel/Condition.cs
Show resolved
Hide resolved
src/Platform/Microsoft.Testing.Extensions.VSTestBridge/ObjectModel/FastFilter.cs
Outdated
Show resolved
Hide resolved
src/Platform/Microsoft.Testing.Extensions.VSTestBridge/ObjectModel/FastFilter.cs
Show resolved
Hide resolved
Co-authored-by: nohwnd <[email protected]>
Summary
Successfully implemented support for filtering uncategorized tests using empty TestCategory values.
Recent Changes
Original prompt
Fixes #5136
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.