Add 'None' tag filter to run or exclude tests without tags#2836
Merged
Conversation
`-TagFilter 'None'` (Filter.Tag) now selects tests that have no tag on themselves or on any parent block, and `-ExcludeTagFilter 'None'` (Filter.ExcludeTag) skips them so only tagged tests run. 'None' is matched case-insensitively and can be combined with real tags. A test literally tagged 'None' is still matched by the filter. Tags inherit downward, so an untagged test inside a tagged block is treated as tagged and is not selected by 'None'. The no-tags rule is applied to leaf tests only, so an untagged block does not force-include or exclude its tagged children. This reserves 'None' as a tag-filter value (breaking change); noted in the 6.0.0 release notes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Update the Filter.Tag and Filter.ExcludeTag option descriptions in FilterConfiguration.cs so the config object, Get-Help, and the generated about_PesterConfiguration help mention that 'None' selects tests without tags. Regenerated the about_PesterConfiguration help text. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a reserved
Nonevalue to the tag filters so you can select tests that have no tags.-TagFilter 'None'/Filter.Tag = 'None'runs only tests with no tag on themselves or on any parent block.-ExcludeTagFilter 'None'/Filter.ExcludeTag = 'None'skips those untagged tests, so only tagged tests run.Noneis matched case-insensitively and can be combined with real tags, e.g.-TagFilter None, Acceptance.Noneis still matched by the filter (normal-likepath), so nothing silently falls through.Tags inherit downward in Pester, so an untagged test inside a tagged block is treated as tagged and is not selected by
None. The no-tags rule is applied to leaf tests only, so an untagged block never force-includes or force-excludes its tagged children.Implementation
Test-HasNoEffectiveTaghelper insrc/Pester.Runtime.ps1walks the item and its parent blocks up to the root, returning$trueonly when no tag is found anywhere.Test-ShouldRuninclude (Filter.Tag) and exclude (Filter.ExcludeTag) sections handleNonebefore the existing-likematching.Breaking change
Noneis now a reserved tag-filter value. Previously it matched a literal tag namedNone; now it means "tests without tags". Documented in the Breaking changes section ofdocs/6.0.0.md.Tests
11 new cases in
tst/Pester.Rspec.Filtering.ts.ps1covering include/exclude, inherited tags, nested untagged blocks, no force-include of tagged siblings, literalNonetag, case-insensitivity, and combiningNonewith another tag.Docs (usage/tags, configuration, v5→v6 migration) are handled in a companion PR in
pester/docs.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com