Skip to content

Commit 074f71a

Browse files
Update docs for test templates (#43316)
* Update docs for test templates * Update the 'a' tags for test frameworks * Fix hyperlinks * Update hyperlinks * undo change * Add section for mstest class * Fix bug with link for mstest class
1 parent f870af7 commit 074f71a

File tree

3 files changed

+95
-5
lines changed

3 files changed

+95
-5
lines changed

docs/core/testing/unit-testing-code-coverage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ namespace System.Numbers
6363
6464
### Create test projects
6565

66-
Create two new **xUnit Test Project (.NET Core)** templates from the same command prompt using the [`dotnet new xunit`](../tools/dotnet-new-sdk-templates.md#test) command:
66+
Create two new **xUnit Test Project (.NET Core)** templates from the same command prompt using the [`dotnet new xunit`](../tools/dotnet-new-sdk-templates.md#xunit) command:
6767

6868
```dotnetcli
6969
dotnet new xunit -n XUnit.Coverlet.Collector

docs/core/tools/dotnet-new-sdk-templates.md

Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ The templates that ship with the .NET SDK have the following additional options:
130130

131131
***
132132

133-
## <a name="test"></a> `mstest`, `xunit`
133+
## <a name="mstest"></a> `mstest`
134134

135135
- **`-f|--framework <FRAMEWORK>`**
136136

@@ -140,6 +140,94 @@ The templates that ship with the .NET SDK have the following additional options:
140140

141141
| SDK version | Default value |
142142
|-------------|-----------------|
143+
| 9.0 | `net9.0` |
144+
| 8.0 | `net8.0` |
145+
| 7.0 | `net7.0` |
146+
| 6.0 | `net6.0` |
147+
| 5.0 | `net5.0` |
148+
| 3.1 | `netcoreapp3.1` |
149+
150+
The ability to create a project for an earlier TFM depends on having that version of the SDK installed. For example, if you have only the .NET 6 SDK installed, then the only value available for `--framework` is `net6.0`. If you install the .NET 5 SDK, the value `net5.0` becomes available for `--framework`. If you install the .NET Core 3.1 SDK, `netcoreapp3.1` becomes available, and so on. So by specifying `--framework netcoreapp3.1` you can target .NET Core 3.1 even while running `dotnet new` in the .NET 6 SDK.
151+
152+
- **`--no-restore`**
153+
154+
Doesn't execute an implicit restore during project creation.
155+
156+
- **`--sdk`**
157+
158+
Use MSTest.Sdk project style.
159+
160+
- **`--test-runner <TEST_RUNNER>`**
161+
162+
The runner/platform for the test project. The possible values are:
163+
164+
- `VSTest` - VSTest platform (Default).
165+
- `MSTest` - MSTest Runner (i.e. Microsoft.Testing.Platform).
166+
167+
- **`--coverage-tool <COVERAGE_TOOL>`**
168+
169+
The coverage tool to use for the test project. The possible values are:
170+
171+
- `Microsoft.CodeCoverage` - Microsoft Code Coverage (Default).
172+
- `coverlet` - coverlet coverage tool.
173+
174+
- **`--extensions-profile <EXTENSIONS_PROFILE>`**
175+
176+
The SDK extensions profile when using MSTest Runner. The possible values are:
177+
178+
- `Default` - Default extensions profile (Default).
179+
- `None` - No extensions are enabled.
180+
- `AllMicrosoft` - Enable all extensions shipped by Microsoft (including extensions with a restrictive license).
181+
182+
- **`--fixture <FIXTURE>`**
183+
184+
The fixture kinds to include in the test project. The possible values are:
185+
186+
- `None` - No fixture methods.
187+
- `AssemblyInitialize` - AssemblyInitialize fixture method.
188+
- `AssemblyCleanup` - AssemblyCleanup fixture method.
189+
- `ClassInitialize` - ClassInitialize fixture method.
190+
- `ClassCleanup` - ClassCleanup fixture method.
191+
- `TestInitialize` - TestInitialize fixture method.
192+
- `TestCleanup` - TestCleanup fixture method.
193+
194+
Where multiple values are allowed.
195+
196+
- **`-p|--enable-pack`**
197+
198+
Enables packaging for the project using [dotnet pack](dotnet-pack.md).
199+
200+
***
201+
202+
## <a name="mstest-class"></a> `mstest-class`
203+
204+
- **`--fixture <FIXTURE>`**
205+
206+
The fixture kinds to include in the test project. The possible values are:
207+
208+
- `None` - No fixture methods.
209+
- `AssemblyInitialize` - AssemblyInitialize fixture method.
210+
- `AssemblyCleanup` - AssemblyCleanup fixture method.
211+
- `ClassInitialize` - ClassInitialize fixture method.
212+
- `ClassCleanup` - ClassCleanup fixture method.
213+
- `TestInitialize` - TestInitialize fixture method.
214+
- `TestCleanup` - TestCleanup fixture method.
215+
216+
Where multiple values are allowed.
217+
218+
***
219+
220+
## <a name="xunit"></a> `xunit`
221+
222+
- **`-f|--framework <FRAMEWORK>`**
223+
224+
Specifies the [framework](../../standard/frameworks.md) to target. Option available since .NET Core 3.0 SDK.
225+
226+
The following table lists the default values according to the SDK version number you're using:
227+
228+
| SDK version | Default value |
229+
|-------------|-----------------|
230+
| 9.0 | `net9.0` |
143231
| 8.0 | `net8.0` |
144232
| 7.0 | `net7.0` |
145233
| 6.0 | `net6.0` |
@@ -158,7 +246,7 @@ The ability to create a project for an earlier TFM depends on having that versio
158246

159247
***
160248

161-
## `nunit`
249+
## <a name="nunit"></a> `nunit`
162250

163251
- **`-f|--framework <FRAMEWORK>`**
164252

@@ -168,6 +256,7 @@ The ability to create a project for an earlier TFM depends on having that versio
168256

169257
| SDK version | Default value |
170258
|-------------|-----------------|
259+
| 9.0 | `net9.0` |
171260
| 8.0 | `net8.0` |
172261
| 7.0 | `net7.0` |
173262
| 6.0 | `net6.0` |

includes/templates.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ The following table shows the templates that come pre-installed with the .NET SD
1111
| Windows Forms (WinForms) Application | [`winforms`](../docs/core/tools/dotnet-new-sdk-templates.md#winforms) | [C#], VB | Common/WinForms | 3.0 (5.0 for VB) |
1212
| Windows Forms (WinForms) Class library | [`winformslib`](../docs/core/tools/dotnet-new-sdk-templates.md#winforms) | [C#], VB | Common/WinForms | 3.0 (5.0 for VB) |
1313
| Worker Service | [`worker`](../docs/core/tools/dotnet-new-sdk-templates.md#web-others) | [C#] | Common/Worker/Web | 3.0 |
14-
| Unit Test Project | [`mstest`](../docs/core/tools/dotnet-new-sdk-templates.md#test) | [C#], F#, VB | Test/MSTest | 1.0 |
14+
| MSTest Test Project | [`mstest`](../docs/core/tools/dotnet-new-sdk-templates.md#mstest) | [C#], F#, VB | Test/MSTest | 1.0 |
15+
| MSTest Test Class | [`mstest-class`](../docs/core/tools/dotnet-new-sdk-templates.md#mstest-class) | [C#], F#, VB | Test/MSTest | 1.0 |
1516
| NUnit 3 Test Project | [`nunit`](../docs/core/tools/dotnet-new-sdk-templates.md#nunit) | [C#], F#, VB | Test/NUnit | 2.1.400 |
1617
| NUnit 3 Test Item | `nunit-test` | [C#], F#, VB | Test/NUnit | 2.2 |
17-
| xUnit Test Project | [`xunit`](../docs/core/tools/dotnet-new-sdk-templates.md#test) | [C#], F#, VB | Test/xUnit | 1.0 |
18+
| xUnit Test Project | [`xunit`](../docs/core/tools/dotnet-new-sdk-templates.md#xunit) | [C#], F#, VB | Test/xUnit | 1.0 |
1819
| Razor Component | `razorcomponent` | [C#] | Web/ASP.NET | 3.0 |
1920
| Razor Page | [`page`](../docs/core/tools/dotnet-new-sdk-templates.md#page) | [C#] | Web/ASP.NET | 2.0 |
2021
| MVC ViewImports | [`viewimports`](../docs/core/tools/dotnet-new-sdk-templates.md#namespace) | [C#] | Web/ASP.NET | 2.0 |

0 commit comments

Comments
 (0)