Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 9, 2025

Please check the following before creating a Pull Request

  • If this is a new feature or piece of functionality, have you started a discussion and gotten agreement on it?
  • If it fixes a bug or problem, is there an issue to track it? If not, create one first and link it please so there's clear visibility.
  • Did you write tests to ensure you code works properly?

Description

TUnit doesn't support VSTest's --filter CLI option. Documentation incorrectly showed using --filter "Category=X" which results in "Unknown option '--filter'" errors.

Changes

  • CI/CD Pipeline Documentation (docs/docs/examples/tunit-ci-pipeline.md)

    • Updated GitHub Actions and GitLab CI examples to use correct tree-node filter syntax
    • Added .NET 10 SDK syntax note
  • Performance Best Practices (docs/docs/advanced/performance-best-practices.md)

    • Updated CI/CD optimization examples to use correct filter syntax

Syntax

Incorrect (VSTest):

dotnet test --filter "Category=Unit"

Correct (TUnit):

# .NET 9 and older
dotnet test -- --treenode-filter "/*/*/*/*[Category=Unit]"

# .NET 10+
dotnet test --treenode-filter "/**[Category=Unit]"

Both dotnet run and dotnet test support the tree-node filter syntax with the -- separator (not needed in .NET 10+).

Original prompt

This section details on the original issue you should resolve

<issue_title>Cannot filter by category</issue_title>
<issue_description>According to the website (https://tunit.dev/docs/examples/tunit-ci-pipeline/#filter-tests-by-category) I should be able to run:

# Unit tests (fast)
- name: Unit Tests
  run: dotnet test --filter "Category=Unit"

# Integration tests (slower)
- name: Integration Tests
  run: dotnet test --filter "Category=Integration"

However, running dotnet test --filter "Category=Integration" yields the following output:

Exit code: 5
  Standard output:
  ████████╗██╗   ██╗███╗   ██╗██╗████████╗
  ╚══██╔══╝██║   ██║████╗  ██║██║╚══██╔══╝
     ██║   ██║   ██║██╔██╗ ██║██║   ██║
     ██║   ██║   ██║██║╚██╗██║██║   ██║
     ██║   ╚██████╔╝██║ ╚████║██║   ██║
     ╚═╝    ╚═════╝ ╚═╝  ╚═══╝╚═╝   ╚═╝

     TUnit v1.5.1.0 | 64-bit | Darwin 25.1.0 Darwin Kernel Version 25.1.0: Mon Oct 20 19:34:05 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6041 | osx-arm64 | .NET 8.0.22 | Microsoft Testing Platform v2.0.2

     Engine Mode: SourceGenerated

  Unknown option '--filter'

and doesn't run any tests.</issue_description>

<agent_instructions>TUnit doesn't support the --filter cli command.
Update the docs to remove the incorrect information, and use the --treenode-filter. Make sure to use the correct syntax for the treenode filter.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@thomhurst I'll fix that. If you're using the .net 10 Sdk try:

dotnet test --treenode-filter "/**[Category=Unit]"</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix filtering issue by category in test execution Fix documentation to use --treenode-filter instead of unsupported --filter syntax Dec 9, 2025
Copilot AI requested a review from thomhurst December 9, 2025 15:43
@thomhurst thomhurst marked this pull request as ready for review December 9, 2025 15:50
Copilot AI review requested due to automatic review settings December 9, 2025 15:50
@thomhurst thomhurst merged commit 82d1771 into main Dec 9, 2025
21 of 25 checks passed
@thomhurst thomhurst deleted the copilot/fix-filter-by-category-issue branch December 9, 2025 15:52
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes critical documentation errors where TUnit-specific CLI syntax was incorrectly shown using VSTest's --filter option, which TUnit does not support. The changes replace incorrect filter syntax with TUnit's --treenode-filter option across CI/CD examples.

  • Updated all examples from --filter "Category=X" to correct -- --treenode-filter "/*/*/*/*[Category=X]" syntax
  • Added helpful notes about .NET 10 SDK's simplified syntax (--treenode-filter "/**[Category=X]") that doesn't require the -- separator
  • Ensures users can successfully filter tests by category in CI/CD pipelines

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
docs/docs/examples/tunit-ci-pipeline.md Fixed GitLab CI and GitHub Actions examples to use correct --treenode-filter syntax; added .NET 10 SDK note
docs/docs/advanced/performance-best-practices.md Fixed CI/CD optimization examples to use correct --treenode-filter syntax; added .NET 10 SDK note

This was referenced Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot filter by category

2 participants