diff --git a/docs/core/testing/unit-testing-with-dotnet-test.md b/docs/core/testing/unit-testing-with-dotnet-test.md index 473c6a13363c0..28deb367d890a 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 062608d4ccc2f..95c1d49e42b0a 100644 --- a/docs/core/tools/dotnet-test.md +++ b/docs/core/tools/dotnet-test.md @@ -11,18 +11,24 @@ ms.date: 03/27/2024 ## 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] @@ -448,7 +454,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 829ba9743ddf3..13492011a2332 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 d1ad48ef454c2..9d7fe0f89e9a5 100644 --- a/docs/core/whats-new/dotnet-10/sdk.md +++ b/docs/core/whats-new/dotnet-10/sdk.md @@ -215,11 +215,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).