You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/core/testing/microsoft-testing-platform-intro.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ The main driving factors for the evolution of the new testing platform are detai
41
41
* MSTest. In MSTest, the support of `Microsoft.Testing.Platform` is done via [MSTest runner](unit-testing-mstest-runner-intro.md).
42
42
* NUnit. In NUnit, the support of `Microsoft.Testing.Platform` is done via [NUnit runner](unit-testing-nunit-runner-intro.md).
43
43
* 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).
44
-
* 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).
44
+
* TUnit: Built entirely on Microsoft.Testing.Platform and doesn't support VSTest. For more information, see [TUnit documentation](https://tunit.dev/) and [Getting started with TUnit](unit-testing-csharp-with-tunit.md).
Copy file name to clipboardExpand all lines: docs/core/testing/unit-testing-code-coverage.md
+46-61Lines changed: 46 additions & 61 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -165,14 +165,25 @@ There are two types of code coverage tools:
165
165
166
166
In this section, the focus is on data collector tools.
167
167
168
-
.NET includes a built-in code coverage data collector, which is also available in Visual Studio. This data collector generates a binary *.coverage* file that can be used to generate reports in Visual Studio. The binary file isn't human-readable, and it must be converted to a human-readable format before it can be used to generate reports outside of Visual Studio.
168
+
### Code coverage approaches
169
+
170
+
.NET provides two different testing platforms, each with its own code coverage approach:
171
+
172
+
-**VSTest-based frameworks** (MSTest, NUnit, xUnit) - Can use either the built-in .NET code coverage collector or [Coverlet](https://github.com/coverlet-coverage/coverlet), an open-source alternative.
The built-in .NET code coverage data collector generates a binary *.coverage* file that can be used to generate reports in Visual Studio. The binary file isn't human-readable, and it must be converted to a human-readable format before it can be used to generate reports outside of Visual Studio.
169
176
170
177
> [!TIP]
171
178
> The `dotnet-coverage` tool is a cross-platform tool that can be used to convert the binary coverage test results file to a human-readable format. For more information, see [dotnet-coverage](../additional-tools/dotnet-coverage.md).
172
179
173
-
[Coverlet](https://github.com/coverlet-coverage/coverlet) is an open-source alternative to the built-in collector. It generates test results as human-readable Cobertura XML files, which can then be used to generate HTML reports. To use Coverlet for code coverage, an existing unit test project must have the appropriate package dependencies, or alternatively rely on [.NET global tooling](../tools/global-tools.md) and the corresponding [coverlet.console](https://www.nuget.org/packages/coverlet.console) NuGet package.
180
+
Coverlet generates test results as human-readable Cobertura XML files, which can then be used to generate HTML reports. To use Coverlet for code coverage, an existing unit test project must have the appropriate package dependencies, or alternatively rely on [.NET global tooling](../tools/global-tools.md) and the corresponding [coverlet.console](https://www.nuget.org/packages/coverlet.console) NuGet package.
181
+
182
+
## Code coverage with VSTest
183
+
184
+
VSTest is the traditional testing platform used by MSTest, NUnit, and xUnit. For VSTest-based projects, you can use either Coverlet or the built-in .NET code coverage collector.
174
185
175
-
##Integrate with .NET test
186
+
### Using Coverlet with VSTest
176
187
177
188
The xUnit test project template already integrates with [coverlet.collector](https://www.nuget.org/packages/coverlet.collector) by default.
178
189
From the command prompt, change directories to the *XUnit.Coverlet.Collector* project, and run the [`dotnet test`](../tools/dotnet-test.md) command:
@@ -295,70 +306,27 @@ After running this command, an HTML file represents the generated report.
TUnit is built on Microsoft.Testing.Platform and uses Microsoft.Testing.Extensions.CodeCoverage for code coverage.
301
-
302
-
### Creating a TUnit test project with code coverage
303
-
304
-
To create a TUnit test project with code coverage support:
305
-
306
-
```dotnetcli
307
-
dotnet new install TUnit.Templates
308
-
dotnet new tunit -n TUnit.CodeCoverage.Test
309
-
```
311
+
[Microsoft.Testing.Platform](microsoft-testing-platform-intro.md) is the modern testing platform for .NET. Frameworks built on this platform use [Microsoft.Testing.Extensions.CodeCoverage](microsoft-testing-platform-extensions-code-coverage.md) for code coverage.
310
312
311
-
Add the project reference to your class library:
313
+
The following frameworks support Microsoft.Testing.Platform:
Since TUnit requires Microsoft.Testing.Platform mode, ensure your `global.json` includes:
329
+
Some frameworks require Microsoft.Testing.Platform mode to be explicitly configured. Add this configuration to your `global.json` file in the solution root:
362
330
363
331
```json
364
332
{
@@ -368,19 +336,36 @@ Since TUnit requires Microsoft.Testing.Platform mode, ensure your `global.json`
368
336
}
369
337
```
370
338
371
-
Run tests with code coverage:
339
+
> [!NOTE]
340
+
> This configuration requires .NET 10 SDK or later. Frameworks like MSTest runner, NUnit runner, and xUnit runner support both VSTest and Microsoft.Testing.Platform, so this configuration is optional for those frameworks. TUnit only supports Microsoft.Testing.Platform, so this configuration is required.
341
+
342
+
### Running code coverage
343
+
344
+
Run tests with code coverage using the `--coverage` flag:
372
345
373
346
```dotnetcli
374
347
dotnet test --coverage
375
348
```
376
349
377
-
This generates a `.coverage` file in the `TestResults` directory. To generate reports in other formats:
350
+
This generates a `.coverage` file in the `TestResults` directory. The `--coverage` flag is specific to Microsoft.Testing.Platform and provides a unified code coverage experience across all supported frameworks.
351
+
352
+
To generate reports in other formats, use the `--coverage-output-format` option:
378
353
379
354
```dotnetcli
380
355
dotnet test --coverage --coverage-output-format cobertura
381
356
```
382
357
383
-
For more information about TUnit, see [Unit testing C# with TUnit](unit-testing-csharp-with-tunit.md).
358
+
Supported output formats include:
359
+
-`coverage` (binary format, default)
360
+
-`cobertura` (XML format)
361
+
-`xml` (XML format)
362
+
363
+
### Framework-specific documentation
364
+
365
+
For detailed information about using Microsoft.Testing.Platform with specific frameworks, see:
366
+
-[Unit testing with MSTest runner](unit-testing-mstest-runner-intro.md)
367
+
-[Unit testing with NUnit runner](unit-testing-nunit-runner-intro.md)
368
+
-[Unit testing C# with TUnit](unit-testing-csharp-with-tunit.md)
Copy file name to clipboardExpand all lines: docs/core/testing/unit-testing-csharp-with-tunit.md
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,11 +8,11 @@ ai-usage: ai-assisted
8
8
---
9
9
# Unit testing C# in .NET using dotnet test and TUnit
10
10
11
-
This tutorial shows how to build a solution containing a unit test project and source code project. To follow the tutorial using a prebuilt solution, [view or download the sample code](https://github.com/dotnet/samples/tree/main/core/getting-started/unit-testing-using-dotnet-test/). For download instructions, see [Samples and Tutorials](../../samples-and-tutorials/index.md#view-and-download-samples).
11
+
This tutorial shows how to build a solution containing a unit test project and source code project step-by-step.
12
12
13
13
## Prerequisites
14
14
15
-
TUnit is built entirely on [Microsoft.Testing.Platform](microsoft-testing-platform-intro.md). Unlike frameworks that support both VSTest and Microsoft.Testing.Platform, TUnit only supports Microsoft.Testing.Platform.
15
+
TUnit is built entirely on [Microsoft.Testing.Platform](microsoft-testing-platform-intro.md) and does not support VSTest.
16
16
17
17
## Create the solution
18
18
@@ -125,6 +125,9 @@ Follow the instructions for "Replace the code in *PrimeService.cs* with the foll
125
125
126
126
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:
127
127
128
+
> [!NOTE]
129
+
> This configuration requires .NET 10 SDK or later.
Copy file name to clipboardExpand all lines: docs/core/testing/unit-testing-fsharp-with-tunit.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,13 +8,13 @@ ai-usage: ai-assisted
8
8
---
9
9
# Unit testing F# libraries in .NET Core using dotnet test and TUnit
10
10
11
-
This tutorial takes you through an interactive experience building a sample solution step-by-step to learn unit testing concepts. If you prefer to follow the tutorial using a pre-built solution, [view or download the sample code](https://github.com/dotnet/samples/tree/main/core/getting-started/unit-testing-with-fsharp/) before you begin. For download instructions, see [Samples and Tutorials](../../samples-and-tutorials/index.md#view-and-download-samples).
11
+
This tutorial takes you through an interactive experience building a sample solution step-by-step to learn unit testing concepts.
12
12
13
13
[!INCLUDE [testing an ASP.NET Core project from .NET Core](../../../includes/core-testing-note-aspnet.md)]
14
14
15
15
## Prerequisites
16
16
17
-
TUnit is built entirely on [Microsoft.Testing.Platform](microsoft-testing-platform-intro.md). Unlike frameworks that support both VSTest and Microsoft.Testing.Platform, TUnit only supports Microsoft.Testing.Platform.
17
+
TUnit is built entirely on [Microsoft.Testing.Platform](microsoft-testing-platform-intro.md) and does not support VSTest.
Copy file name to clipboardExpand all lines: docs/core/testing/unit-testing-visual-basic-with-tunit.md
+14-21Lines changed: 14 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,11 +8,11 @@ ai-usage: ai-assisted
8
8
---
9
9
# Unit testing Visual Basic .NET Core libraries using dotnet test and TUnit
10
10
11
-
This tutorial shows how to build a solution containing a unit test project and library project. To follow the tutorial using a pre-built solution, [view or download the sample code](https://github.com/dotnet/samples/tree/main/core/getting-started/unit-testing-using-dotnet-test/). For download instructions, see [Samples and Tutorials](../../samples-and-tutorials/index.md#view-and-download-samples).
11
+
This tutorial shows how to build a solution containing a unit test project and library project step-by-step.
12
12
13
13
## Prerequisites
14
14
15
-
TUnit is built entirely on [Microsoft.Testing.Platform](microsoft-testing-platform-intro.md). Unlike frameworks that support both VSTest and Microsoft.Testing.Platform, TUnit only supports Microsoft.Testing.Platform.
15
+
TUnit is built entirely on [Microsoft.Testing.Platform](microsoft-testing-platform-intro.md) and does not support VSTest.
16
16
17
17
## Create the solution
18
18
@@ -102,8 +102,6 @@ The following instructions provide the steps to create the test solution. See [C
0 commit comments