Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/core/testing/unit-testing-code-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace System.Numbers

### Create test projects

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:
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:

```dotnetcli
dotnet new xunit -n XUnit.Coverlet.Collector
Expand Down
93 changes: 91 additions & 2 deletions docs/core/tools/dotnet-new-sdk-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ The templates that ship with the .NET SDK have the following additional options:

***

## <a name="test"></a> `mstest`, `xunit`
## <a name="mstest"></a> `mstest`

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

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

| SDK version | Default value |
|-------------|-----------------|
| 9.0 | `net9.0` |
| 8.0 | `net8.0` |
| 7.0 | `net7.0` |
| 6.0 | `net6.0` |
| 5.0 | `net5.0` |
| 3.1 | `netcoreapp3.1` |

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.

- **`--no-restore`**

Doesn't execute an implicit restore during project creation.

- **`--sdk`**

Use MSTest.Sdk project style.

- **`--test-runner <TEST_RUNNER>`**

The runner/platform for the test project. The possible values are:

- `VSTest` - VSTest platform (Default).
- `MSTest` - MSTest Runner (i.e. Microsoft.Testing.Platform).

- **`--coverage-tool <COVERAGE_TOOL>`**

The coverage tool to use for the test project. The possible values are:

- `Microsoft.CodeCoverage` - Microsoft Code Coverage (Default).
- `coverlet` - coverlet coverage tool.

- **`--extensions-profile <EXTENSIONS_PROFILE>`**

The SDK extensions profile when using MSTest Runner. The possible values are:

- `Default` - Default extensions profile (Default).
- `None` - No extensions are enabled.
- `AllMicrosoft` - Enable all extensions shipped by Microsoft (including extensions with a restrictive license).

- **`--fixture <FIXTURE>`**

The fixture kinds to include in the test project. The possible values are:

- `None` - No fixture methods.
- `AssemblyInitialize` - AssemblyInitialize fixture method.
- `AssemblyCleanup` - AssemblyCleanup fixture method.
- `ClassInitialize` - ClassInitialize fixture method.
- `ClassCleanup` - ClassCleanup fixture method.
- `TestInitialize` - TestInitialize fixture method.
- `TestCleanup` - TestCleanup fixture method.

Where multiple values are allowed.

- **`-p|--enable-pack`**

Enables packaging for the project using [dotnet pack](dotnet-pack.md).

***

## <a name="mstest-class"></a> `mstest-class`

- **`--fixture <FIXTURE>`**

The fixture kinds to include in the test project. The possible values are:

- `None` - No fixture methods.
- `AssemblyInitialize` - AssemblyInitialize fixture method.
- `AssemblyCleanup` - AssemblyCleanup fixture method.
- `ClassInitialize` - ClassInitialize fixture method.
- `ClassCleanup` - ClassCleanup fixture method.
- `TestInitialize` - TestInitialize fixture method.
- `TestCleanup` - TestCleanup fixture method.

Where multiple values are allowed.

***

## <a name="xunit"></a> `xunit`

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

Specifies the [framework](../../standard/frameworks.md) to target. Option available since .NET Core 3.0 SDK.

The following table lists the default values according to the SDK version number you're using:

| SDK version | Default value |
|-------------|-----------------|
| 9.0 | `net9.0` |
| 8.0 | `net8.0` |
| 7.0 | `net7.0` |
| 6.0 | `net6.0` |
Expand All @@ -158,7 +246,7 @@ The ability to create a project for an earlier TFM depends on having that versio

***

## `nunit`
## <a name="nunit"></a> `nunit`

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

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

| SDK version | Default value |
|-------------|-----------------|
| 9.0 | `net9.0` |
| 8.0 | `net8.0` |
| 7.0 | `net7.0` |
| 6.0 | `net6.0` |
Expand Down
5 changes: 3 additions & 2 deletions includes/templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ The following table shows the templates that come pre-installed with the .NET SD
| Windows Forms (WinForms) Application | [`winforms`](../docs/core/tools/dotnet-new-sdk-templates.md#winforms) | [C#], VB | Common/WinForms | 3.0 (5.0 for VB) |
| 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) |
| Worker Service | [`worker`](../docs/core/tools/dotnet-new-sdk-templates.md#web-others) | [C#] | Common/Worker/Web | 3.0 |
| Unit Test Project | [`mstest`](../docs/core/tools/dotnet-new-sdk-templates.md#test) | [C#], F#, VB | Test/MSTest | 1.0 |
| MSTest Test Project | [`mstest`](../docs/core/tools/dotnet-new-sdk-templates.md#mstest) | [C#], F#, VB | Test/MSTest | 1.0 |
| MSTest Test Class | [`mstest-class`](../docs/core/tools/dotnet-new-sdk-templates.md#mstest-class) | [C#], F#, VB | Test/MSTest | 1.0 |
| NUnit 3 Test Project | [`nunit`](../docs/core/tools/dotnet-new-sdk-templates.md#nunit) | [C#], F#, VB | Test/NUnit | 2.1.400 |
| NUnit 3 Test Item | `nunit-test` | [C#], F#, VB | Test/NUnit | 2.2 |
| xUnit Test Project | [`xunit`](../docs/core/tools/dotnet-new-sdk-templates.md#test) | [C#], F#, VB | Test/xUnit | 1.0 |
| xUnit Test Project | [`xunit`](../docs/core/tools/dotnet-new-sdk-templates.md#xunit) | [C#], F#, VB | Test/xUnit | 1.0 |
| Razor Component | `razorcomponent` | [C#] | Web/ASP.NET | 3.0 |
| Razor Page | [`page`](../docs/core/tools/dotnet-new-sdk-templates.md#page) | [C#] | Web/ASP.NET | 2.0 |
| MVC ViewImports | [`viewimports`](../docs/core/tools/dotnet-new-sdk-templates.md#namespace) | [C#] | Web/ASP.NET | 2.0 |
Expand Down
Loading