RFC 016: Filter command-line option#8820
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new draft design RFC (RFC 016) describing a user-friendly --filter <expression> command-line option for Microsoft.Testing.Platform (MTP), intended to supersede --treenode-filter while preserving backward compatibility via a deprecated alias.
Changes:
- Introduces a proposed filter expression grammar with kind-prefixed predicates and a bare-value shorthand.
- Proposes new extensibility and public API surfaces (
FilterMatchTextProperty,ITestNodeFilterKindProvider,TestNodeFilterKind, etc.) to let frameworks/bridges register filter kinds. - Outlines help/info integration, validation rules, migration plan, and open design questions for review.
Show a summary per file
| File | Description |
|---|---|
| docs/RFCs/016-Filter-Command-Line-Option.md | New RFC draft specifying the --filter option design, extensibility model, and migration/back-compat plan. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 3
Replace --treenode-filter with a first-class --filter <expression> option built on a small prefix-routed grammar (kind=value, kind~value, bare-value), plus an extensibility surface so test frameworks and bridges can register their own filter kinds. Driving issue: #4293 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
c7fbf4a to
14b11e4
Compare
|
On the question of inner alternation/conjunction ( Short answer: no, not for v1. I've added this as Open Question #9 in the RFC and propose deferring it. Three approaches were considered:
For v1 I'd rather ship the smaller, unambiguous surface and match VSTest exactly (VSTest itself does not support inner See Open Question #9 in 14b11e4 for the same rationale captured in the RFC. |
|
@bradwilson @OsirisTerje @thomhurst — pinging you as test framework owners (xUnit / NUnit / TUnit). This RFC proposes a new @MarcoRossignoli @Youssef1313 — would also appreciate your eyes on the design before we move toward implementation. |
|
A big thing to think about for this I think is llms. For TUnit, they get confused and try to use old vstest expressions a lot. I think good error messages should help them with this though. |
|
Also are we opening up custom built extensions at all? I'd be happy to keep the existing treenode filter command line since users already use it, but would rather do it cleanly with actual filter types in the code, than workarounds |
|
What about the source based |
I think you're just going to anger users if your |
|
The goal is to merge the various options all together with a small caveat for when no prefix is specified. Let's take as example |
|
Should anything be changed for xUnit.net v3 4.0 in the face of this proposal? Should I remove the I'm concerned not only with whether this new version of |
|
Reading through the whole RFC, it appears that If this is true, I need to remove |
I think before trying to smush everything together, we should support extensible filters and allowing extension authors to define their own. I thought MTP was meant to be quite agnostic and I opinionated, but in terms of filters, it offers no extensibility and is completely opinionated currently. Being opinionated isn't necessarily bad imo because it keeps test frameworks having similar expected filters. But I think not allowing us to offer more custom options is a real extensibility blocker |
I really dislike that MTP doesn't have a way to have a "hidden" option. We use this in xUnit.net frequently when transitioning from one syntax to another to preserve backward compatibility without listing the explicit back-compat option. Example: when reporters became user configurable, and we switched all reporters from their short form (e.g., |
This is explicitly called out in the Open Questions section (and deferred to be addressed later):
What that potential implementation probably means is that things won't necessarily work when they're expected to, and the user is expected to see and interpret the warning to understand why. To be fair, there's no good answer here: Do you "hope for the best" and just run things, hoping the user knows that some of the filter is inapplicable to some of the test projects? Or do you refuse to run, making is hard or impossible for users to craft together a single query for solutions which target multiple test frameworks? Really only Microsoft knows (or could know) how often people are in such situations; I don't really field many questions at all about mixing xUnit.net with other test frameworks. |
I haven't look at xUnit v4, I suppose you register I'll sleep on it and think about what I could do.
Nothing is set in stone yet but I have tried to work on #8501 to help with that. I also did #7113 which we could probably combine. I am not against us all discussing and designing a different solution.
In this RFC, I am discussing the way to add prefix and the related handler logic which should in-part cover this need. I'll get back to your various open tickets around filter extensibility to see how to open it more.
Mixed framework is more of a niche than mass thing but it's something that exist (especially for more mature products). I know this is a problem we have with the fact we don't have enough common filters. When we started design of MTP, I was hoping to the new filter to be "enforced" on all frameworks so we could have a filter covering most of the scenario for all frameworks but sadly because of the various internal pushbacks we are in some situation. Maybe we should have claimed some more general options to cause less issues. Again I was naively hoping we would be allowed more time and we could all work together on the growing specs rather than us all moving on our side (not a blame, more of a reality check). Overall maybe this design is interesting but would need to be applied only to a next breaking change version of MTP and for now we only move with adding more |
There was a problem hiding this comment.
I'm extremely opposed to creating yet a new --filter. This is going to be really confusing.
If any change is to be taken here, I would simply just drop our treenode filter (in next major) which is only used by TUnit.
The platform cannot do much about filtering anyways. It's up to test frameworks to do the filtering because the framework is where the knowledge of running the tests is.
Simply put, I would just keep the VSTest-based filtering in the VSTestBridge. For frameworks that don't use the bridge, they can use the VSTest source only package to provide the --filter support.
I think the best path forward is to just keep everything similar to VSTest filtering. That's really the least problematic approach to the ecosystem.
| 2. **No `--filter`.** The single most-typed test-filter option in the .NET | ||
| ecosystem (`dotnet test --filter "FullyQualifiedName~Foo"`) does not work | ||
| with MTP today. Users hit `Unknown option '--filter'` and assume MTP is | ||
| broken or hostile to their workflows. |
There was a problem hiding this comment.
That's not very true.
--filter is supported by MSTest and NUnit.
The support was missing in xunit.v3 but we are filling the gap now in xunit.v3 4.x. We shouldn't degrade this after we worked towards resolving it.
MTP doesn't need to have the knowledge of FQN. It's test framework responsibility to filter. |
Draft RFC for #4293.
Summary
Replaces
--treenode-filterwith a first-class--filter <expression>option, built on a small prefix-routed grammar (kind=value,kind~value, bare value) that aligns with the existing graph-query grammar and reads naturally for users coming from VSTest.The RFC also:
FilterMatchTextPropertyas the dedicated default match target for bare filter values (with fallback toDisplayName), so frameworks decide what--filter Foomatches against without us conflating it with display text.ITestNodeFilterKindProvider/TestNodeFilterKindso test frameworks and bridges (first customer: the VSTest bridge withTestCategory,Priority,Owner,Trait) can register their own filter kinds.--treenode-filteras a deprecated alias for--filter Query=...for one release window.Built-in kinds
DisplayName,Uid,Query(absorbs today's tree-node grammar),Namespace,ClassName,MethodName,FullyQualifiedName(synthesized).Status
Draft for design review. Implementation work (TestNode property, parser, predicate evaluator, VSTest bridge wiring, MSTest rollout,
--help/--infosnapshot updates) is intentionally out of scope until the RFC is approved.Open questions
There are 8 design questions explicitly called out in the RFC's "Open questions" section that I'd like reviewer input on before turning this into code — including bare-value fallback to DisplayName, default case sensitivity, wildcard support,
Trait=name=valueshape, and the mixed-framework solution scenario.cc @nohwnd