-
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. |
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.
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.
Updated
| | 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? 👀
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.
Err ignore that 😅 Fixed it.
|
|
||
| ## 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
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 is what I get for using AI. It hallucinated that! Removed!
| :::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.
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.
Updated them
| | 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.
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'll make a note to update TUnit templates
| 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?
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.
Updated
|
|
||
| ```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.
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.
Added
| 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.
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.
Sorry what do you mean RootNamespace? I think this should be consistent with other VB examples?
|
|
||
| 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?
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.
Fixed
….Platform and adjust related content across multiple files
…and VB documentation
|
Thanks for the comments @Evangelink and @Youssef1313 - Have made changes |
…nks in C# and VB documentation
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