-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Enhance documentation for TUnit integration and usage #50094
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
…nit tests documentation with TUnit filter syntax
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.
Pull request overview
This PR enhances documentation for TUnit, a .NET testing framework built entirely on Microsoft.Testing.Platform, by adding comprehensive tutorials, examples, and integration guides across multiple languages and scenarios.
- Adds complete TUnit getting-started tutorials for C#, F#, and Visual Basic with test-driven development (TDD) workflows.
- Expands Microsoft.Testing.Platform documentation to show that extensions work with TUnit alongside MSTest, NUnit, and xUnit.
- Provides practical examples for filtering tests, ordering with dependencies, code coverage setup, and mutation testing with TUnit.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/core/testing/unit-testing-visual-basic-with-tunit.md | New tutorial for unit testing Visual Basic with TUnit, including project setup, test creation, and parameterized tests. |
| docs/core/testing/unit-testing-fsharp-with-tunit.md | New tutorial for unit testing F# with TUnit, demonstrating the test-driven development approach for functional code. |
| docs/core/testing/unit-testing-csharp-with-tunit.md | New tutorial for unit testing C# with TUnit, showing async test patterns and source generation features. |
| docs/core/testing/unit-testing-code-coverage.md | Added section on using code coverage with TUnit, including project setup and Microsoft.Testing.Extensions.CodeCoverage integration. |
| docs/core/testing/selective-unit-tests.md | Added TUnit examples for filtering tests using --treenode-filter flag with path-based syntax and attribute filtering. |
| docs/core/testing/order-unit-tests.md | Added TUnit section demonstrating [DependsOn] attribute for controlling test execution order through explicit dependencies. |
| docs/core/testing/mutation-testing.md | Added TUnit examples for mutation testing with Stryker.NET using async test patterns. |
| docs/core/testing/microsoft-testing-platform-intro.md | Updated TUnit description to clarify it only supports Microsoft.Testing.Platform and added link to getting started guide. |
| docs/core/testing/index.md | Enhanced TUnit section with detailed feature description and links to language-specific tutorials. |
|
|
||
| ### Behavior | ||
|
|
||
| * **Failure handling** - By default, if a dependency fails, the dependent test is skipped. You can override this behavior by setting `ProceedOnFailure = true` on the `DependsOnAttribute`. |
Copilot
AI
Nov 22, 2025
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.
According to the Markdown writing style guidelines, list items with more than three words must end with a period. This bullet point has more than three words and is missing the ending period.
| ### Behavior | ||
|
|
||
| * **Failure handling** - By default, if a dependency fails, the dependent test is skipped. You can override this behavior by setting `ProceedOnFailure = true` on the `DependsOnAttribute`. | ||
| * **Accessing dependent test context** - You can retrieve data from a prerequisite test's context using the `GetTests` method on the `TestContext` object. |
Copilot
AI
Nov 22, 2025
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.
According to the Markdown writing style guidelines, list items with more than three words must end with a period. This bullet point has more than three words and is missing the ending period.
|
|
||
| * **Failure handling** - By default, if a dependency fails, the dependent test is skipped. You can override this behavior by setting `ProceedOnFailure = true` on the `DependsOnAttribute`. | ||
| * **Accessing dependent test context** - You can retrieve data from a prerequisite test's context using the `GetTests` method on the `TestContext` object. | ||
| * **Multiple dependencies** - You can apply multiple `[DependsOn]` attributes to a single test to create complex dependency chains. |
Copilot
AI
Nov 22, 2025
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.
According to the Markdown writing style guidelines, list items with more than three words must end with a period. This bullet point has more than three words and is missing the ending period.
| * NUnit. In NUnit, the support of `Microsoft.Testing.Platform` is done via [NUnit runner](unit-testing-nunit-runner-intro.md). | ||
| * xUnit.net: In xUnit.net, the support of `Microsoft.Testing.Platform` is done via [xUnit.net runner](https://xunit.net/docs/getting-started/v3/microsoft-testing-platform). | ||
| * TUnit: entirely constructed on top of the `Microsoft.Testing.Platform`, for more information, see [TUnit documentation](https://tunit.dev/). | ||
| * TUnit: Built entirely on Microsoft.Testing.Platform and doesn't support VSTest. Unlike MSTest, NUnit, and xUnit which support both VSTest and MTP, TUnit only supports MTP. For more information, see [TUnit documentation](https://tunit.dev/) and [Getting started with TUnit](unit-testing-csharp-with-tunit.md). |
Copilot
AI
Nov 22, 2025
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.
According to the Markdown writing style guidelines, use the Oxford comma in all lists. The phrase "MSTest, NUnit, and xUnit" needs a comma before "and" (Oxford comma). Change "MSTest, NUnit and xUnit" to "MSTest, NUnit, and xUnit".
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
Please take a look. |
Evangelink
left a comment
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.
@Youssef1313 and @nohwnd for extra reviews.
| * NUnit. In NUnit, the support of `Microsoft.Testing.Platform` is done via [NUnit runner](unit-testing-nunit-runner-intro.md). | ||
| * xUnit.net: In xUnit.net, the support of `Microsoft.Testing.Platform` is done via [xUnit.net runner](https://xunit.net/docs/getting-started/v3/microsoft-testing-platform). | ||
| * TUnit: entirely constructed on top of the `Microsoft.Testing.Platform`, for more information, see [TUnit documentation](https://tunit.dev/). | ||
| * TUnit: Built entirely on Microsoft.Testing.Platform and doesn't support VSTest. Unlike MSTest, NUnit, and xUnit which support both VSTest and MTP, TUnit only supports MTP. For more information, see [TUnit documentation](https://tunit.dev/) and [Getting started with TUnit](unit-testing-csharp-with-tunit.md). |
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.
I wonder if we should skip the part Unlike MSTest, NUnit, and xUnit which support both VSTest and MTP, TUnit only supports MTP.
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.
I agree. I would focus more on info about TUnit rather than making it more of a comparison.
| | xUnit | `FullyQualifiedName`<br>`DisplayName`<br>`Traits` | | ||
| | Nunit | `FullyQualifiedName`<br>`Name`<br>`Priority`<br>`TestCategory` | | ||
| | NUnit | `FullyQualifiedName`<br>`Name`<br>`Priority`<br>`TestCategory` | | ||
| | TUnit | `FullyQualifiedName`<br>`Name`<br>`Category`<br>`Property` | |
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.
Let's take this opportunity to reorder by name the test framework please.
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.
Does TUnit implement the VSTest-based filter syntax? 👀
|
|
||
| ## Using code coverage with TUnit | ||
|
|
||
| TUnit is built on Microsoft.Testing.Platform and uses Microsoft.Testing.Extensions.CodeCoverage for code coverage. |
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.
I think we could link MTP and MTP CC pages here.
|
|
||
| ## Configure Microsoft.Testing.Platform mode | ||
|
|
||
| TUnit only supports Microsoft.Testing.Platform and doesn't support VSTest. To use `dotnet test` with TUnit, add the following configuration to your `global.json` file in the solution root: |
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.
Let's mention this is only available when .NET10+ SDK is installed.
| * NUnit. In NUnit, the support of `Microsoft.Testing.Platform` is done via [NUnit runner](unit-testing-nunit-runner-intro.md). | ||
| * xUnit.net: In xUnit.net, the support of `Microsoft.Testing.Platform` is done via [xUnit.net runner](https://xunit.net/docs/getting-started/v3/microsoft-testing-platform). | ||
| * TUnit: entirely constructed on top of the `Microsoft.Testing.Platform`, for more information, see [TUnit documentation](https://tunit.dev/). | ||
| * TUnit: Built entirely on Microsoft.Testing.Platform and doesn't support VSTest. Unlike MSTest, NUnit, and xUnit which support both VSTest and MTP, TUnit only supports MTP. For more information, see [TUnit documentation](https://tunit.dev/) and [Getting started with TUnit](unit-testing-csharp-with-tunit.md). |
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.
I agree. I would focus more on info about TUnit rather than making it more of a comparison.
|
|
||
| ## Using mutation testing with TUnit | ||
|
|
||
| Mutation testing with Stryker.NET works with TUnit. The examples above can be written using TUnit's async testing syntax: |
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.
How does it work? I thought MTP isn't yet supported by Stryker.NET stryker-mutator/stryker-net#3094
| :::code language="csharp" source="snippets/order-unit-tests/csharp/NUnit.TestProject/ByOrder.cs"::: | ||
|
|
||
| :::zone-end | ||
| :::zone pivot="tunit" |
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 need to update docs/zone-pivot-groups.yml for this to work, I think.
| | xUnit | `FullyQualifiedName`<br>`DisplayName`<br>`Traits` | | ||
| | Nunit | `FullyQualifiedName`<br>`Name`<br>`Priority`<br>`TestCategory` | | ||
| | NUnit | `FullyQualifiedName`<br>`Name`<br>`Priority`<br>`TestCategory` | | ||
| | TUnit | `FullyQualifiedName`<br>`Name`<br>`Category`<br>`Property` | |
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.
Does TUnit implement the VSTest-based filter syntax? 👀
| dotnet new install TUnit.Templates | ||
| dotnet new tunit -n TUnit.CodeCoverage.Test |
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.
Does the template add/update global.json to set test runner as MTP?
|
|
||
| ## Configure Microsoft.Testing.Platform mode | ||
|
|
||
| TUnit only supports Microsoft.Testing.Platform and doesn't support VSTest. To use `dotnet test` with TUnit, add the following configuration to your `global.json` file in the solution root: |
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.
It's best IMO to let TUnit templates do this on its own.
| Return Task.Run(Async Function() | ||
| Dim result As Boolean = _primeService.IsPrime(1) | ||
| Await Assert.That(result).IsFalse() | ||
| End Function) |
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.
Why this complexity? I think you should be able to declare the function as async, and await in it directly instead of returning a task created by Task.Run?
|
|
||
| ```vb | ||
| <Test> | ||
| Function IsPrime_InputIs1_ReturnFalse() As Task |
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.
Probably better to be explicit about the accessibility and add Public.
| Imports TUnit.Assertions.Extensions | ||
| Imports TUnit.Core | ||
|
|
||
| Namespace PrimeService.Tests |
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.
Can you please ensure that this doesn't duplicate the namespace?
IIRC, VB already uses RootNamespace, and having explicit namespace is duplicating it. But I might be misremembering.
|
|
||
| Namespace PrimeService.Tests | ||
| Public Class PrimeService_IsPrimeShould | ||
| Private ReadOnly _primeService As Prime.Services.PrimeService |
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.
Why not add Imports Prime.Services instead of fully qualifying?
This pull request expands documentation for TUnit, a .NET testing framework built on Microsoft.Testing.Platform, and clarifies its support for various extensibility features and workflows. The changes improve coverage of TUnit in comparison to other frameworks, add practical examples for advanced scenarios (such as filtering, ordering, code coverage, and mutation testing), and update documentation to show that Microsoft.Testing.Platform extensions work with TUnit.
TUnit documentation enhancements:
dotnet test --filter, including supported attributes and operator usage. [1] [2][DependsOn]attribute, covering dependency handling, failure behavior, and method overloads.Integration with Microsoft.Testing.Platform extensions:
Advanced testing scenarios with TUnit:
Internal previews