diff --git a/docs/core/testing/unit-testing-code-coverage.md b/docs/core/testing/unit-testing-code-coverage.md index 0968bbea537e8..0acfa449a5221 100644 --- a/docs/core/testing/unit-testing-code-coverage.md +++ b/docs/core/testing/unit-testing-code-coverage.md @@ -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 diff --git a/docs/core/tools/dotnet-new-sdk-templates.md b/docs/core/tools/dotnet-new-sdk-templates.md index 5e25b67bb3a90..0cd9133e389aa 100644 --- a/docs/core/tools/dotnet-new-sdk-templates.md +++ b/docs/core/tools/dotnet-new-sdk-templates.md @@ -130,7 +130,7 @@ The templates that ship with the .NET SDK have the following additional options: *** -## `mstest`, `xunit` +## `mstest` - **`-f|--framework `** @@ -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 `** + + 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 `** + + 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 `** + + 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 `** + + 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). + +*** + +## `mstest-class` + +- **`--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. + +*** + +## `xunit` + +- **`-f|--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` | @@ -158,7 +246,7 @@ The ability to create a project for an earlier TFM depends on having that versio *** -## `nunit` +## `nunit` - **`-f|--framework `** @@ -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` | diff --git a/includes/templates.md b/includes/templates.md index d117106463897..0a6f149a8b212 100644 --- a/includes/templates.md +++ b/includes/templates.md @@ -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 |