Skip to content

Conversation

@thomhurst
Copy link
Contributor

@thomhurst thomhurst commented Nov 22, 2025

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:

  • Added detailed description of TUnit, including its use of source generation, parallel test execution, and links to official documentation and language-specific guides. [1] [2]
  • Added comprehensive examples for filtering TUnit tests with dotnet test --filter, including supported attributes and operator usage. [1] [2]
  • Provided an example of ordering TUnit tests using the [DependsOn] attribute, covering dependency handling, failure behavior, and method overloads.

Integration with Microsoft.Testing.Platform extensions:

  • Clarified that Microsoft.Testing.Platform extensions for output, test reports, code coverage, and architecture work with TUnit, in addition to MSTest, NUnit, and xUnit. [1] [2] [3] [4]

Advanced testing scenarios with TUnit:

  • Added sections on using code coverage tools (e.g., Coverlet, ReportGenerator) and mutation testing (Stryker.NET) with TUnit, including async test patterns and project setup instructions. [1] [2] [3]

Internal previews

📄 File 🔗 Preview link
docs/core/testing/index.md Testing in .NET
docs/core/testing/microsoft-testing-platform-intro.md Microsoft.Testing.Platform overview
docs/core/testing/mutation-testing.md Mutation testing
docs/core/testing/order-unit-tests.md Order unit tests
docs/core/testing/selective-unit-tests.md Run selected unit tests
docs/core/testing/unit-testing-code-coverage.md docs/core/testing/unit-testing-code-coverage
docs/core/testing/unit-testing-csharp-with-tunit.md Unit testing C# in .NET using dotnet test and TUnit
docs/core/testing/unit-testing-fsharp-with-tunit.md Unit testing F# in .NET Core with dotnet test and TUnit
docs/core/testing/unit-testing-visual-basic-with-tunit.md Unit testing Visual Basic .NET Core libraries using dotnet test and TUnit

Copilot AI review requested due to automatic review settings November 22, 2025 16:40
@thomhurst thomhurst requested review from a team and IEvangelist as code owners November 22, 2025 16:40
@dotnetrepoman dotnetrepoman bot added this to the November 2025 milestone Nov 22, 2025
@dotnet-policy-service dotnet-policy-service bot added dotnet-fundamentals/svc community-contribution Indicates PR is created by someone from the .NET community. labels Nov 22, 2025
Copilot finished reviewing on behalf of thomhurst November 22, 2025 16:44
Copy link
Contributor

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 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`.
Copy link

Copilot AI Nov 22, 2025

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.

Copilot generated this review using guidance from repository custom instructions.
### 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.
Copy link

Copilot AI Nov 22, 2025

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.

Copilot generated this review using guidance from repository custom instructions.

* **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.
Copy link

Copilot AI Nov 22, 2025

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.

Copilot generated this review using guidance from repository custom instructions.
* 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).
Copy link

Copilot AI Nov 22, 2025

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".

Copilot generated this review using guidance from repository custom instructions.
@BillWagner
Copy link
Member

@YoushanMicrosoft @Evangelink

Please take a look.

Copy link
Member

@Evangelink Evangelink left a 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).
Copy link
Member

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.

Copy link
Member

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` |
Copy link
Member

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.

Copy link
Member

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.
Copy link
Member

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:
Copy link
Member

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).
Copy link
Member

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:
Copy link
Member

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"
Copy link
Member

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` |
Copy link
Member

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? 👀

Comment on lines +307 to +308
dotnet new install TUnit.Templates
dotnet new tunit -n TUnit.CodeCoverage.Test
Copy link
Member

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:
Copy link
Member

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.

Comment on lines +210 to +213
Return Task.Run(Async Function()
Dim result As Boolean = _primeService.IsPrime(1)
Await Assert.That(result).IsFalse()
End Function)
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates PR is created by someone from the .NET community. dotnet-fundamentals/svc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants