From 93ea2a095879dccf7ee86302882e2454f33d30bb Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Tue, 14 Oct 2025 22:35:27 +0200 Subject: [PATCH 1/4] Document MTP v1 to v2 migration (#48673) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Document MTP v1 to v2 migration * markdownlint * Apply suggestions from code review Co-authored-by: Jakub Jareš Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> * Consistency * xref * More xrefs * Clarify * Cleanup * Fix markdownlint * Update docs/core/testing/microsoft-testing-platform-migration-from-v1-to-v2.md Co-authored-by: Jakub Jareš * Apply suggestions from code review Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --------- Co-authored-by: Jakub Jareš Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- ...esting-platform-migration-from-v1-to-v2.md | 71 +++++++++++++++++++ .../unit-testing-mstest-migration-v3-v4.md | 2 +- docs/navigate/devops-testing/toc.yml | 6 +- 3 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 docs/core/testing/microsoft-testing-platform-migration-from-v1-to-v2.md diff --git a/docs/core/testing/microsoft-testing-platform-migration-from-v1-to-v2.md b/docs/core/testing/microsoft-testing-platform-migration-from-v1-to-v2.md new file mode 100644 index 0000000000000..5d300df35e400 --- /dev/null +++ b/docs/core/testing/microsoft-testing-platform-migration-from-v1-to-v2.md @@ -0,0 +1,71 @@ +--- +title: Migrating from Microsoft.Testing.Platform v1 to v2 +description: Learn how to migrate to Microsoft.Testing.Platform v2 and understand the key changes. +author: Youssef1313 +ms.author: ygerges +ms.date: 10/08/2025 +--- + +# Mirate from Microsoft.Testing.Platform v1 to v2 + +The stable version Microsoft.Testing.Platform v2 is now available. This migration guide explores what's changed in Microsoft.Testing.Platform v2 and how you can migrate to this version. + +## Source breaking changes + +These are breaking changes that might cause build errors after migration. + +### Dropped unsupported target frameworks + +Support for target frameworks from .NET Core 3.1 to .NET 7 is dropped. The minimum supported .NET version is .NET 8. +This change doesn't affect .NET Framework. .NET Framework 4.6.2 continues to be the minimum supported .NET Framework target. + +### Removed obsolete types + +The following types were marked obsolete in MTP v1. In MTP v2, they are removed completely: + +- `ITestApplicationLifecycleCallbacks`: use `ITestHostApplicationLifetime` instead. +- `TestNodeFileArtifact`: use `FileArtifactProperty` instead. +- `KeyValuePairStringProperty`: use `TestMetadataProperty` instead. +- `TestSessionContext.Client`: use `IClientInfo` instead. + +This breaking change doesn't affect typical users of test frameworks. It only affects test framework authors and extension authors. + +### API signature changes + +- A `CancellationToken` parameter was added to . +- Methods in interface are changed to have an `ITestSessionContext` parameter instead of both and parameters. +- `IDataConsumer` is moved from `Microsoft.Testing.Platform.Extensions.TestHost` namespace to `Microsoft.Testing.Platform.Extensions`. + +This breaking change doesn't affect typical users of test frameworks. It only affects test framework authors and extension authors. + +## Behavior breaking changes + +These are breaking changes that might affect the behavior at run time. + +### Compatibility with VSTest-based `dotnet test` + +The `dotnet test` command has two implementations: + +- VSTest-based implementation: this was the only implementation up to .NET 9 SDK. +- MTP-based implementation: this was added starting in .NET 10 SDK. + +Running MTP test projects with .NET 10 SDK now requires opting-in to the MTP-based `dotnet test` and can no longer be run with the VSTest-based implementation, which was previously enabled by `TestingPlatformDotnetTestSupport` MSBuild property in MTP v1. + +To opt-in the MTP-based implementation, create global.json in repository or solution root (or update existing global.json if you have one already), to have test runner set as Microsoft.Testing.Platform, as shown in the following example: + +```json +{ + "test": { + "runner": "Microsoft.Testing.Platform" + } +} +``` + +Attempting to run the VSTest-based `dotnet test` with MTP v2 will produce the following error: + +> Testing with VSTest target is no longer supported by Microsoft.Testing.Platform on .NET 10 SDK and later. If you use dotnet test, you should opt-in to the new dotnet test experience. For more information, see + +### Rename of command-line options + +- The `--diagnostic-output-fileprefix` command-line option was renamed to `--diagnostic-file-prefix`. +- The `--diagnostic-filelogger-synchronouswrite` command-line option was renamed to `--diagnostic-synchronous-write`. diff --git a/docs/core/testing/unit-testing-mstest-migration-v3-v4.md b/docs/core/testing/unit-testing-mstest-migration-v3-v4.md index ec4de037f2b96..145add5d519f5 100644 --- a/docs/core/testing/unit-testing-mstest-migration-v3-v4.md +++ b/docs/core/testing/unit-testing-mstest-migration-v3-v4.md @@ -6,7 +6,7 @@ ms.author: ygerges ms.date: 07/22/2025 --- -# Migrate from MSTest v3 to MSTest v4 +# Migrate from MSTest v3 to v4 The stable version MSTest v4 is now available. This migration guide explores what's changed in MSTest v4 and how you can migrate to this version. diff --git a/docs/navigate/devops-testing/toc.yml b/docs/navigate/devops-testing/toc.yml index 9356d2a89e479..981d64055cb2e 100644 --- a/docs/navigate/devops-testing/toc.yml +++ b/docs/navigate/devops-testing/toc.yml @@ -71,12 +71,14 @@ items: items: - name: Overview href: ../../core/testing/unit-testing-mstest-intro.md - - name: Migrate MSTest from v1 to v3 + - name: Migrate from MSTest v1 to v3 href: ../../core/testing/unit-testing-mstest-migration-from-v1-to-v3.md - - name: Migrate from MSTest v3 to MSTest v4 + - name: Migrate from MSTest v3 to v4 href: ../../core/testing/unit-testing-mstest-migration-v3-v4.md - name: Microsoft.Testing.Platform support (MSTest runner) href: ../../core/testing/unit-testing-mstest-runner-intro.md + - name: Migrate from Microsoft.Testing.Platform v1 to v2 + href: ../../core/testing/microsoft-testing-platform-migration-from-v1-to-v2.md - name: Getting started items: - name: Overview From 62f96234f4c7eef299d9e0f9cfc8a3d613dbb189 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Tue, 14 Oct 2025 22:35:51 +0200 Subject: [PATCH 2/4] Testing docs improvements (#48494) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Testing docs improvements * markdownlint * Update docs/core/testing/microsoft-testing-platform-vs-vstest.md * Apply suggestions from code review Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> * Update docs/core/testing/migrating-vstest-microsoft-testing-platform.md Co-authored-by: Jakub Jareš * Fix lint --------- Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Co-authored-by: Jakub Jareš --- docs/core/testing/index.md | 6 +- .../microsoft-testing-platform-vs-vstest.md | 78 +------ ...ating-vstest-microsoft-testing-platform.md | 209 ++++++++++++++++++ docs/navigate/devops-testing/toc.yml | 2 + 4 files changed, 218 insertions(+), 77 deletions(-) create mode 100644 docs/core/testing/migrating-vstest-microsoft-testing-platform.md diff --git a/docs/core/testing/index.md b/docs/core/testing/index.md index ebe3166710c1a..27060a7c1ca5c 100644 --- a/docs/core/testing/index.md +++ b/docs/core/testing/index.md @@ -39,9 +39,11 @@ When running tests in .NET, there are two components involved: the test platform ### Test platforms -The test platform is the engine that runs the tests and acts as a communication channel with IDEs. For example, Visual Studio can send a discovery request to the test platform so that it can display the available tests in Test Explorer. The test platform responds back to the IDE with the tests it found. Similar communication happens for test execution. +The test platform is the engine that runs the tests and acts as a communication channel with IDEs and CLI. For example, Visual Studio can send a discovery request to the test platform so that it can display the available tests in Test Explorer. The test platform responds back to the IDE with the tests it found. Similar communication happens for test execution. -VSTest has been used for many years in .NET and was the only test platform in the ecosystem. Early in 2024, the first stable version of a new test platform, called [Microsoft.Testing.Platform (MTP)](./microsoft-testing-platform-intro.md), was released. +VSTest has been used for many years in .NET and was the only test platform in the ecosystem. Early in 2024, the first stable version of a new test platform, called [Microsoft.Testing.Platform (MTP)](./microsoft-testing-platform-intro.md), was released. For more information about migrating from VSTest to Microsoft.Testing.Platform, see [Migration guide from VSTest to Microsoft.Testing.Platform](./migrating-vstest-microsoft-testing-platform.md). + +The test platform also provides extensibility APIs so that additional features can be implemented and made available for all test frameworks. There are usually built-in features built on top of the extensibility APIs, such as TRX reporting and hang and crash dumps. The community can also build custom extensions that work for all test frameworks. ### Test frameworks diff --git a/docs/core/testing/microsoft-testing-platform-vs-vstest.md b/docs/core/testing/microsoft-testing-platform-vs-vstest.md index 8ce80848f29a3..ff449033332b5 100644 --- a/docs/core/testing/microsoft-testing-platform-vs-vstest.md +++ b/docs/core/testing/microsoft-testing-platform-vs-vstest.md @@ -53,80 +53,8 @@ You can also go to Preview Features options in Visual Studio and deselect the "U ## Executables -VSTest ships multiple executables, notably `vstest.console.exe`, `testhost.exe`, and `datacollector.exe`. However, MSTest is embedded directly into your test project and doesn't ship any other executables. The executable your test project compiles to is used to host all the testing tools and carry out all the tasks needed to run tests. +VSTest ships multiple executables, notably `vstest.console.exe`, `testhost.exe`, and `datacollector.exe`. However, Microsoft.Testing.Platform is embedded directly into your test project and doesn't ship any other executables. The executable your test project compiles to is used to host all the testing tools and carry out all the tasks needed to run tests. -## Migrating from VSTest +## See also -In addition to the steps specific to your test framework, you need to update your test infrastructure to accommodate to `Microsoft.Testing.Platform`. - -### `dotnet test` - -Command line options of `dotnet test` are divided into 2 categories: build related arguments and test related ones. - -The build related arguments are passed to the `dotnet build` command and as such don't need to be updated for the new platform. Build related arguments are listed below: - -- `-a|--arch ` -- `--artifacts-path ` -- `-c|--configuration ` -- `-f|--framework ` -- `-e|--environment ` -- `--interactive` -- `--no-build` -- `--nologo` -- `--no-restore` -- `-o|--output ` -- `--os ` -- `-r|--runtime ` -- `-v|--verbosity ` - -The test related arguments are VSTest specific and so need to be transformed to match the new platform. The following table shows the mapping between the VSTest arguments and the new platform: - -| VSTest argument | New platform argument | -|-----------------|-----------------------| -| `--test-adapter-path ` | Not supported | -| `--blame` | Not supported | -| `--blame-crash` | `--crashdump` requires [Crash dump extension](./microsoft-testing-platform-extensions-diagnostics.md#crash-dump) | -| `--blame-crash-dump-type ` | `--crashdump-type` requires [Crash dump extension](./microsoft-testing-platform-extensions-diagnostics.md#crash-dump) | -| `--blame-crash-collect-always` | Not supported | -| `--blame-hang` | `--hangdump` requires [Hang dump extension](./microsoft-testing-platform-extensions-diagnostics.md#hang-dump) | -| `--blame-hang-dump-type ` | `--hangdump-type` requires [Hang dump extension](./microsoft-testing-platform-extensions-diagnostics.md#hang-dump) | -| `--blame-hang-timeout ` | `--hangdump-timeout` requires [Hang dump extension](./microsoft-testing-platform-extensions-diagnostics.md#hang-dump) | -| `--collect ` | Depends on the data collector | -| `-d\|--diag ` | `--diagnostic` | -| `--filter ` | Depends upon the selected test framework | -| `-l\|--logger ` | Depends on the logger | -| `--results-directory ` | `--results-directory ` | -| `-s\|--settings ` | Depends upon the selected test framework | -| `-t\|--list-tests` | `--list-tests` | -| `-- ` | `--test-parameter` (provided by [VSTestBridge](microsoft-testing-platform-extensions-vstest-bridge.md)) | - -> [!IMPORTANT] -> Before specifying any `Microsoft.Testing.Platform` arguments, you need to add `--` to separate the `dotnet test` arguments from the new platform arguments. For example, `dotnet test --no-build -- --list-tests`. - -### `vstest.console.exe` - -If you are using `vstest.console.exe` directly, we recommend replacing it with the `dotnet test` command. - -### Test Explorer - -When using Visual Studio or Visual Studio Code Test Explorer, you might need to enable the support for the new test platform. - -#### Visual Studio - -Visual Studio Test Explorer supports the new test platform starting with version 17.14. If you are using an earlier version, you might need to update your Visual Studio to the latest version. - -#### Visual Studio Code - -Visual Studio Code with C# DevKit supports the new test platform. - -### Azure DevOps - -When using Azure DevOps tasks, you might need to update your pipeline to use the new test platform. - -#### VSTest task - -If you're using the [VSTest task](/azure/devops/pipelines/tasks/reference/vstest-v3) in Azure DevOps, you can replace it with the [.NET Core task](/azure/devops/pipelines/tasks/reference/dotnet-core-cli-v2). - -#### .NET Core task - -If you're using the [.NET Core task](/azure/devops/pipelines/tasks/reference/dotnet-core-cli-v2), no changes are needed. +- [Migration guide from VSTest to Microsoft.Testing.Platform](./migrating-vstest-microsoft-testing-platform.md) diff --git a/docs/core/testing/migrating-vstest-microsoft-testing-platform.md b/docs/core/testing/migrating-vstest-microsoft-testing-platform.md new file mode 100644 index 0000000000000..55db1fadb84eb --- /dev/null +++ b/docs/core/testing/migrating-vstest-microsoft-testing-platform.md @@ -0,0 +1,209 @@ +--- +title: Migration guide from VSTest to Microsoft.Testing.Platform +description: Learn how to migrate from VSTest to Microsoft.Testing.Platform +author: Youssef1313 +ms.author: ygerges +ms.date: 09/15/2025 +--- + +# Migrate from VSTest to Microsoft.Testing.Platform + +In this article, you learn how to migrate from VSTest to Microsoft.Testing.Platform. + +## Opt-in to use Microsoft.Testing.Platform + +The first step in the migration is to opt-in to using Microsoft.Testing.Platform. + +For all test frameworks, add `Exe` to all test projects in the solution. After that, follow the framework-specific guidance. + +### MSTest + +Microsoft.Testing.Platform is supported by MSTest starting with 3.2.0. However, we recommend updating to the latest available MSTest version. + +To opt-in, add `true` under a `PropertyGroup` in [`Directory.Build.props`](/visualstudio/msbuild/customize-by-directory) file. + +> [!NOTE] +> When using MSTest.Sdk, Microsoft.Testing.Platform is used by default, unless `true` is specified. + +### NUnit + +Microsoft.Testing.Platform is supported by NUnit3TestAdapter starting with 5.0.0. + +To opt-in, add `true` under a `PropertyGroup` in [`Directory.Build.props`](/visualstudio/msbuild/customize-by-directory) file. + +### xUnit.net + +Microsoft.Testing.Platform is supported starting with xunit.v3. + +To opt-in, add `true` under a `PropertyGroup` in [`Directory.Build.props`](/visualstudio/msbuild/customize-by-directory) file. + +## `dotnet test` + +### Opt-in for .NET 9 SDK and earlier + +In .NET 9 SDK and earlier, there is no *native* support for Microsoft.Testing.Platform for `dotnet test`. Support is built on top of the VSTest infrastructure. To use that, add `true` under a `PropertyGroup` in [`Directory.Build.props`](/visualstudio/msbuild/customize-by-directory) file. + +> [!IMPORTANT] +> When running Microsoft.Testing.Platform support in this mode, you need to add `--` to separate the `dotnet test` arguments from the new platform arguments. For example, `dotnet test --no-build -- --list-tests`. + +### Opt-in for .NET 10 SDK and later + +Starting with .NET 10 SDK, there is *native* support for Microsoft.Testing.Platform. To use it, you must specify the test runner as `Microsoft.Testing.Platform` in *global.json*: + +```json +{ + "test": { + "runner": "Microsoft.Testing.Platform" + } +} +``` + +> [!IMPORTANT] +> In this mode, the extra `--` is no longer used. + +### Update `dotnet test` invocations + +Command line options of `dotnet test` are divided into two categories: build-related arguments and test-related ones. + +The build-related arguments are irrelevant to the test platform and as such don't need to be updated for the new platform. Build-related arguments are listed here: + +- `-a|--arch ` +- `--artifacts-path ` +- `-c|--configuration ` +- `-f|--framework ` +- `-e|--environment ` +- `--interactive` +- `--no-build` +- `--nologo` +- `--no-restore` +- `-o|--output ` +- `--os ` +- `-r|--runtime ` +- `-v|--verbosity ` + +The test-related arguments are VSTest specific and so need to be transformed to match the new platform. The following table shows the mapping between the VSTest arguments and the new platform: + +| VSTest argument | New platform argument | +|-----------------|-----------------------| +| `--test-adapter-path ` | Not relevant for Microsoft.Testing.Platform | +| `--blame` | Not relevant for Microsoft.Testing.Platform | +| `--blame-crash` | `--crashdump` (requires [Crash dump extension](./microsoft-testing-platform-extensions-diagnostics.md#crash-dump)) | +| `--blame-crash-dump-type ` | `--crashdump-type` (requires [Crash dump extension](./microsoft-testing-platform-extensions-diagnostics.md#crash-dump)) | +| `--blame-crash-collect-always` | Not supported | +| `--blame-hang` | `--hangdump` (requires [Hang dump extension](./microsoft-testing-platform-extensions-diagnostics.md#hang-dump)) | +| `--blame-hang-dump-type ` | `--hangdump-type` (requires [Hang dump extension](./microsoft-testing-platform-extensions-diagnostics.md#hang-dump)) | +| `--blame-hang-timeout ` | `--hangdump-timeout` (requires [Hang dump extension](./microsoft-testing-platform-extensions-diagnostics.md#hang-dump)) | +| `--collect ` | Depends on the data collector | +| `-d\|--diag ` | `--diagnostic` | +| `--filter ` | Depends upon the selected test framework | +| `-l\|--logger ` | Depends on the logger | +| `--results-directory ` | `--results-directory ` | +| `-s\|--settings ` | Depends upon the selected test framework | +| `-t\|--list-tests` | `--list-tests` | +| `-- ` | `--test-parameter` (provided by [VSTestBridge](microsoft-testing-platform-extensions-vstest-bridge.md)) | + +#### `--collect` + +`--collect` is a general extensibility point in VSTest for any data collector. The extensibility model of Microsoft.Testing.Platform is different and there is no such centralized argument to be used by all data collectors. With Microsoft.Testing.Platform, each data collector can add its own command-line option. For example, running Microsoft CodeCoverage through VSTest might be similar to the following: + +```dotnetcli +dotnet test --collect "Code Coverage;Format=cobertura" +``` + +With Microsoft.Testing.Platform, this becomes: + +```dotnetcli +dotnet test --coverage --coverage-output-format cobertura +``` + +> [!IMPORTANT] +> As explained earlier, when using Microsoft.Testing.Platform with the VSTest-based `dotnet test`, extra `--` is needed before the arguments intended to be passed to the platform. +> So, this becomes `dotnet test -- --coverage --coverage-output-format cobertura`. + +#### `--filter` + +`--filter` is the VSTest-based filter. + +MSTest and NUnit support the same filter format even when running with Microsoft.Testing.Platform. + +xUnit.net, does not support the same filter format when running with Microsoft.Testing.Platform. You must migrate from the VSTest-based filter to the new filter support in xunit.v3, which is provided using the following command-line options. + +xUnit.net specific options: + +- `--filter-class` +- `--filter-not-class` +- `--filter-method` +- `--filter-not-method` +- `--filter-namespace` +- `--filter-not-namespace` +- `--filter-trait` +- `--filter-not-trait` +- `--filter-query` + +For more information, see [Microsoft.Testing.Platform documentation for xUnit.net](https://xunit.net/docs/getting-started/v3/microsoft-testing-platform) and [Query Filter Language for xUnit.net](https://xunit.net/docs/query-filter-language). + +#### `--logger` + +What was usually referred to as "logger" in VSTest is referred to as "reporter" in Microsoft.Testing.Platform. In Microsoft.Testing.Platform, logging is explicitly for diagnosing purposes only. + +Similar to `--collect`, `--logger` is a general extensibility point in VSTest for any logger (or, in the context of Microsoft.Testing.Platform, any *reporter*). Each Microsoft.Testing.Platform reporter is free to add its own command-line option, and as such there is no centralized command-line option like VSTest's `--logger`. + +One of the very commonly used VSTest loggers is the TRX logger. This logger is usually called as follows: + +```dotnetcli +dotnet test --logger trx +``` + +With Microsoft.Testing.Platform, the command becomes: + +```dotnetcli +dotnet test --report-trx +``` + +> [!IMPORTANT] +> To use `--report-trx`, you must have the `Microsoft.Testing.Extensions.TrxReport` NuGet package installed. +> +> [!IMPORTANT] +> As explained earlier, when using Microsoft.Testing.Platform with the VSTest-based `dotnet test`, extra `--` is needed before the arguments intended to be passed to the platform. +> So, this becomes `dotnet test -- --report-trx`. + +#### `--settings` + +VSTest's `--settings` is used to specify a RunSettings file for the test run. RunSettings isn't supported by the core Microsoft.Testing.Platform and was replaced by a more modern [`testconfig.json`](./microsoft-testing-platform-config.md) configuration file. However, MSTest and NUnit still support the old RunSettings when running Microsoft.Testing.Platform and `--settings` is still supported. + +## `vstest.console.exe` + +If you are using `vstest.console.exe` directly, we recommend replacing it with the `dotnet test` command. + +## Test Explorer + +When using Visual Studio or Visual Studio Code Test Explorer, you might need to enable the support for Microsoft.Testing.Platform. + +### Visual Studio + +Visual Studio Test Explorer supports Microsoft.Testing.Platform starting with version 17.14. If you are using an earlier version, you might need to update your Visual Studio to the latest version. + +### Visual Studio Code + +Visual Studio Code with C# DevKit supports Microsoft.Testing.Platform. + +## Azure DevOps + +When using Azure DevOps tasks, you might need to update your pipeline to use Microsoft.Testing.Platform, depending on which task you use. + +### VSTest task + +If you're using the [VSTest task](/azure/devops/pipelines/tasks/reference/vstest-v3) in Azure DevOps, you can replace it with the [.NET Core task](/azure/devops/pipelines/tasks/reference/dotnet-core-cli-v2). + +### .NET Core CLI task + +- If you have custom `arguments` passed to the task, follow the same guidance for `dotnet test` migration. +- If you're using the [DotNetCoreCLI](/azure/devops/pipelines/tasks/reference/dotnet-core-cli-v2) task without opting-in to the native Microsoft.Testing.Platform experience for .NET 10 SDK and later via `global.json` file, you need to set the task `arguments` to correctly point to the results directory it used to point to, as well as the requested TRX report. For example: + + ```yml + - task: DotNetCoreCLI@2 + displayName: Run unit tests + inputs: + command: 'test' + arguments: '-- --report-trx --results-directory $(Agent.TempDirectory) + ``` diff --git a/docs/navigate/devops-testing/toc.yml b/docs/navigate/devops-testing/toc.yml index 981d64055cb2e..08e4bd195bf13 100644 --- a/docs/navigate/devops-testing/toc.yml +++ b/docs/navigate/devops-testing/toc.yml @@ -249,6 +249,8 @@ items: href: ../../core/testing/microsoft-testing-platform-faq.md - name: Comparison with VSTest href: ../../core/testing/microsoft-testing-platform-vs-vstest.md + - name: Migrate from VSTest to Microsoft.Testing.Platform + href: ../../core/testing/migrating-vstest-microsoft-testing-platform.md - name: Configure the test platform href: ../../core/testing/microsoft-testing-platform-config.md - name: Extensions From 5989952d6f3fc2a2ab7dcd0d23175fa019f46906 Mon Sep 17 00:00:00 2001 From: Mariam Abdullah <122357303+mariam-abdulla@users.noreply.github.com> Date: Tue, 14 Oct 2025 22:44:10 +0200 Subject: [PATCH 3/4] Replace dotnet.config with global.json in dotnet test (#48295) * replace dotnet.config with global.json * Remove occurences of dotnet.config * Add link of global.json * Update docs/core/testing/unit-testing-with-dotnet-test.md Co-authored-by: Youssef Victor * Update global.json doc * Update docs/core/tools/global-json.md Co-authored-by: Youssef Victor * Update docs/core/tools/global-json.md Co-authored-by: Youssef Victor --------- Co-authored-by: Youssef Victor --- .../testing/unit-testing-with-dotnet-test.md | 15 +++++++----- docs/core/tools/dotnet-test.md | 24 ++++++++++++------- docs/core/tools/global-json.md | 23 ++++++++++++++++++ docs/core/whats-new/dotnet-10/sdk.md | 11 +++++---- 4 files changed, 54 insertions(+), 19 deletions(-) diff --git a/docs/core/testing/unit-testing-with-dotnet-test.md b/docs/core/testing/unit-testing-with-dotnet-test.md index df5a680a908a3..c57dc5e2871da 100644 --- a/docs/core/testing/unit-testing-with-dotnet-test.md +++ b/docs/core/testing/unit-testing-with-dotnet-test.md @@ -91,11 +91,14 @@ Due to these issues, .NET has introduced a new `dotnet test` mode specifically d To address the issues encountered when running `dotnet test` with MTP in VSTest mode, .NET introduced a new mode in the .NET 10 SDK that's specifically designed for MTP. -To enable this mode, add a `dotnet.config` file to the root of the repository or solution. - -```ini -[dotnet.test.runner] -name = "Microsoft.Testing.Platform" +To enable this mode, add the following configuration to your `global.json` file: + +```json +{ + "test": { + "runner": "Microsoft.Testing.Platform" + } +} ``` > [!IMPORTANT] @@ -123,7 +126,7 @@ Since this mode is specifically designed for Microsoft.Testing.Platform, neither For users of MTP that are using the VSTest mode of `dotnet test`, there are few actions needed to migrate to the newer `dotnet test` experience: -1. Add `dotnet.config` in the root of your repository, as shown above. +1. Add `test` section to your `global.json` file, as shown above. 1. Remove `TestingPlatformDotnetTestSupport` MSBuild property, as it's no longer required. 1. Remove `TestingPlatformCaptureOutput` and `TestingPlatformShowTestsFailure` MSBuild properties, as they are no longer used by the new `dotnet test`. 1. Remove the extra `--`, for example `dotnet test -- --report-trx` should become `dotnet test --report-trx`. diff --git a/docs/core/tools/dotnet-test.md b/docs/core/tools/dotnet-test.md index 89523205d4654..c1a5656259d00 100644 --- a/docs/core/tools/dotnet-test.md +++ b/docs/core/tools/dotnet-test.md @@ -13,18 +13,24 @@ ms.date: 09/29/2025 ## Description -The `dotnet test` command builds the solution and runs the tests with either VSTest or Microsoft Testing Platform (MTP). To enable MTP, you need to add a config file named `dotnet.config` with an INI-like format located at the root of the solution or repository. +The `dotnet test` command builds the solution and runs the tests with either VSTest or Microsoft Testing Platform (MTP). To enable MTP, you need to specify the test runner in the `global.json` file. -Some examples of the `dotnet.config` file: +Some examples of how to specify the test runner in the [`global.json`](global-json.md) file: - ```ini - [dotnet.test.runner] - name = "Microsoft.Testing.Platform" + ```json + { + "test": { + "runner": "Microsoft.Testing.Platform" + } + } ``` - ```ini - [dotnet.test.runner] - name = "VSTest" + ```json + { + "test": { + "runner": "VSTest" + } + } ``` > [!IMPORTANT] @@ -454,7 +460,7 @@ dotnet test -h|--help With Microsoft Testing Platform, `dotnet test` operates faster than with VSTest. The test-related arguments are no longer fixed, as they are tied to the registered extensions in the test project(s). Moreover, MTP supports a globbing filter when running tests. For more information, see [Microsoft.Testing.Platform](../testing/microsoft-testing-platform-intro.md). > [!WARNING] -> When Microsoft.Testing.Platform is opted in via `dotnet.config`, `dotnet test` expects all test projects to use Microsoft.Testing.Platform. It is an error if any of the test projects use VSTest. +> When Microsoft.Testing.Platform is opted in via `global.json`, `dotnet test` expects all test projects to use Microsoft.Testing.Platform. It is an error if any of the test projects use VSTest. #### Implicit restore diff --git a/docs/core/tools/global-json.md b/docs/core/tools/global-json.md index 84ae20c64bdb8..beae45bd263a1 100644 --- a/docs/core/tools/global-json.md +++ b/docs/core/tools/global-json.md @@ -112,6 +112,19 @@ Type: `object` Lets you control the project SDK version in one place rather than in each individual project. For more information, see [How project SDKs are resolved](/visualstudio/msbuild/how-to-use-project-sdk#how-project-sdks-are-resolved). +### `test` + +- Type: `object` + +Specifies information about tests. + +### `runner` + +- Type: `string` +- Available since: .NET 10.0 SDK. + +The test runner to discover/run tests with. + ### Comments in global.json Comments in *global.json* files are supported using JavaScript or C# style comments. For example: @@ -195,6 +208,16 @@ The following example shows how to specify additional SDK search paths and a cus } ``` +The following example shows how to specify `Microsoft.Testing.Platform` as the test runner: + +```json +{ + "test": { + "runner": "Microsoft.Testing.Platform" + } +} +``` + ## global.json and the .NET CLI To set an SDK version in the *global.json* file, it's helpful to know which SDK versions are installed on your machine. For information on how to do that, see [How to check that .NET is already installed](../install/how-to-detect-installed-versions.md#check-sdk-versions). diff --git a/docs/core/whats-new/dotnet-10/sdk.md b/docs/core/whats-new/dotnet-10/sdk.md index 8114cdbebf459..9e28c2e120bce 100644 --- a/docs/core/whats-new/dotnet-10/sdk.md +++ b/docs/core/whats-new/dotnet-10/sdk.md @@ -218,11 +218,14 @@ A new `` property allows you to explicitly set the format ## Support for Microsoft Testing Platform in `dotnet test` -Starting in .NET 10, `dotnet test` natively supports [Microsoft.Testing.Platform](../../testing/microsoft-testing-platform-intro.md). To enable this feature, add the following configuration to your *dotnet.config* file: +Starting in .NET 10, `dotnet test` natively supports [Microsoft.Testing.Platform](../../testing/microsoft-testing-platform-intro.md). To enable this feature, add the following configuration to your *global.json* file: -```ini -[dotnet.test.runner] -name = "Microsoft.Testing.Platform" +```json +{ + "test": { + "runner": "Microsoft.Testing.Platform" + } +} ``` For more details, see [Testing with `dotnet test`](../../testing/unit-testing-with-dotnet-test.md). From 3d28536fcd762a21e49407315b6fad866f1e7250 Mon Sep 17 00:00:00 2001 From: kurnakovv <59327306+kurnakovv@users.noreply.github.com> Date: Wed, 15 Oct 2025 08:07:51 +0900 Subject: [PATCH 4/4] Add code example for CA1716 rule (#48956) (#48957) * Add code example for CA1716 rule (#48956) * Delete VB from languages (#48956) --- .../code-analysis/quality-rules/ca1716.md | 6 ++++++ .../snippets/csharp/all-rules/ca1716.cs | 13 +++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1716.cs diff --git a/docs/fundamentals/code-analysis/quality-rules/ca1716.md b/docs/fundamentals/code-analysis/quality-rules/ca1716.md index 7bc744fd4a850..992a6eecd9132 100644 --- a/docs/fundamentals/code-analysis/quality-rules/ca1716.md +++ b/docs/fundamentals/code-analysis/quality-rules/ca1716.md @@ -10,6 +10,8 @@ helpviewer_keywords: - CA1716 author: gewarren ms.author: gewarren +dev_langs: +- CSharp --- # CA1716: Identifiers should not match keywords @@ -43,6 +45,10 @@ Case-insensitive comparison is used for Visual Basic keywords, and case-sensitiv Select a name that does not appear in the list of keywords. +## Example + +:::code language="csharp" source="snippets/csharp/all-rules/ca1716.cs" id="snippet1"::: + ## When to suppress warnings You can suppress a warning from this rule if you're sure that the identifier won't confuse users of the API, and that the library is usable in all available languages in .NET. diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1716.cs b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1716.cs new file mode 100644 index 0000000000000..0f8eba0e729e9 --- /dev/null +++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1716.cs @@ -0,0 +1,13 @@ +namespace ca1716 +{ + // + // This code violates the rule. + public class Class { } + public class Event { } + public class String { } + public class Namespace { } + public class Object { } + public class Public { } + public class Static { } + // +}