Skip to content

Commit 5989952

Browse files
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 <youssefvictor00@gmail.com> * Update global.json doc * Update docs/core/tools/global-json.md Co-authored-by: Youssef Victor <youssefvictor00@gmail.com> * Update docs/core/tools/global-json.md Co-authored-by: Youssef Victor <youssefvictor00@gmail.com> --------- Co-authored-by: Youssef Victor <youssefvictor00@gmail.com>
1 parent 62f9623 commit 5989952

File tree

4 files changed

+54
-19
lines changed

4 files changed

+54
-19
lines changed

docs/core/testing/unit-testing-with-dotnet-test.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,14 @@ Due to these issues, .NET has introduced a new `dotnet test` mode specifically d
9191
9292
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.
9393
94-
To enable this mode, add a `dotnet.config` file to the root of the repository or solution.
95-
96-
```ini
97-
[dotnet.test.runner]
98-
name = "Microsoft.Testing.Platform"
94+
To enable this mode, add the following configuration to your `global.json` file:
95+
96+
```json
97+
{
98+
"test": {
99+
"runner": "Microsoft.Testing.Platform"
100+
}
101+
}
99102
```
100103
101104
> [!IMPORTANT]
@@ -123,7 +126,7 @@ Since this mode is specifically designed for Microsoft.Testing.Platform, neither
123126
124127
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:
125128
126-
1. Add `dotnet.config` in the root of your repository, as shown above.
129+
1. Add `test` section to your `global.json` file, as shown above.
127130
1. Remove `TestingPlatformDotnetTestSupport` MSBuild property, as it's no longer required.
128131
1. Remove `TestingPlatformCaptureOutput` and `TestingPlatformShowTestsFailure` MSBuild properties, as they are no longer used by the new `dotnet test`.
129132
1. Remove the extra `--`, for example `dotnet test -- --report-trx` should become `dotnet test --report-trx`.

docs/core/tools/dotnet-test.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,24 @@ ms.date: 09/29/2025
1313

1414
## Description
1515

16-
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.
16+
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.
1717

18-
Some examples of the `dotnet.config` file:
18+
Some examples of how to specify the test runner in the [`global.json`](global-json.md) file:
1919

20-
```ini
21-
[dotnet.test.runner]
22-
name = "Microsoft.Testing.Platform"
20+
```json
21+
{
22+
"test": {
23+
"runner": "Microsoft.Testing.Platform"
24+
}
25+
}
2326
```
2427

25-
```ini
26-
[dotnet.test.runner]
27-
name = "VSTest"
28+
```json
29+
{
30+
"test": {
31+
"runner": "VSTest"
32+
}
33+
}
2834
```
2935

3036
> [!IMPORTANT]
@@ -454,7 +460,7 @@ dotnet test -h|--help
454460
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).
455461

456462
> [!WARNING]
457-
> 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.
463+
> 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.
458464
459465
#### Implicit restore
460466

docs/core/tools/global-json.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,19 @@ Type: `object`
112112

113113
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).
114114

115+
### `test`
116+
117+
- Type: `object`
118+
119+
Specifies information about tests.
120+
121+
### `runner`
122+
123+
- Type: `string`
124+
- Available since: .NET 10.0 SDK.
125+
126+
The test runner to discover/run tests with.
127+
115128
### Comments in global.json
116129

117130
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
195208
}
196209
```
197210

211+
The following example shows how to specify `Microsoft.Testing.Platform` as the test runner:
212+
213+
```json
214+
{
215+
"test": {
216+
"runner": "Microsoft.Testing.Platform"
217+
}
218+
}
219+
```
220+
198221
## global.json and the .NET CLI
199222

200223
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).

docs/core/whats-new/dotnet-10/sdk.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,14 @@ A new `<ContainerImageFormat>` property allows you to explicitly set the format
218218
219219
## Support for Microsoft Testing Platform in `dotnet test`
220220
221-
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:
221+
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:
222222
223-
```ini
224-
[dotnet.test.runner]
225-
name = "Microsoft.Testing.Platform"
223+
```json
224+
{
225+
"test": {
226+
"runner": "Microsoft.Testing.Platform"
227+
}
228+
}
226229
```
227230
228231
For more details, see [Testing with `dotnet test`](../../testing/unit-testing-with-dotnet-test.md).

0 commit comments

Comments
 (0)