Skip to content

Commit 9baaad3

Browse files
denisekartegil
andauthored
docs: Update test project template usage (#626)
Updates documentation regarding the use of bUnit template for creating test projects that target xUnit, NUnit or MSTest testing framework. refs: #129 Co-authored-by: Egil Hansen <egil@assimilated.dk>
1 parent b46fc08 commit 9baaad3

1 file changed

Lines changed: 26 additions & 6 deletions

File tree

docs/site/docs/getting-started/create-test-project.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ title: Creating a new bUnit test project
55

66
# Creating a new bUnit test project
77

8-
To write tests, you need a place to put them - a test project. bUnit is not a unit test runner, so a general-purpose test framework like xUnit, NUnit, or MSTest is needed in addition to bUnit in order to write and run tests.
8+
To write tests, you need a place to put them - a test project. bUnit is not a unit test runner, so a general-purpose test framework like xUnit, NUnit, or MSTest is needed in addition to bUnit in order to write and run tests.
99

10-
To use bUnit with xUnit, the easiest approach is to use the bUnit project template described in the [Create a test project with bUnit template](#creating-a-test-project-with-bunit-template) section further down the page. To create a test project manually and in a general-purpose testing frameworks agnostic way, read the following section.
10+
To use bUnit, the easiest approach is to use the bUnit project template described in the [Create a test project with bUnit template](#creating-a-test-project-with-bunit-template) section further down the page. To create a test project manually and in a general-purpose testing frameworks agnostic way, read the following section.
1111

1212
## Creating a test project manually
1313

@@ -57,7 +57,7 @@ dotnet add package bunit --version #{NBGV_NuGetPackageVersion}#
5757

5858
**3. Configure project settings**
5959

60-
The test projects setting needs to be set to the following:
60+
The test projects setting needs to be set to the following:
6161

6262
- the project's SDK needs to be set to `Microsoft.NET.Sdk.Razor`
6363
- set the `<TargetFramework>` to `net6.0`
@@ -176,7 +176,7 @@ The result should be a test project with a `.csproj` that looks like this (non b
176176

177177
## Creating a test project with bUnit template
178178

179-
To skip a few steps in the guide above, use the [bUnit test project template](https://www.nuget.org/packages/bunit.template/). The bUnit project template currently only works with the xUnit general-purpose testing framework, but other frameworks will be supported in the future.
179+
To skip a few steps in the guide above, use the [bUnit test project template](https://www.nuget.org/packages/bunit.template/).
180180

181181
The steps for creating a test project with the bUnit template are as follows:
182182

@@ -198,11 +198,31 @@ dotnet new --install bunit.template::#{NBGV_NuGetPackageVersion}#
198198

199199
Use the following command to create a bUnit with xUnit test project:
200200

201+
# [xUnit](#tab/xunit)
202+
201203
```dotnetcli
202-
dotnet new bunit -o <NAME OF TEST PROJECT>
204+
dotnet new bunit --framework xunit -o <NAME OF TEST PROJECT>
203205
```
204206

205-
The `-o` option in the `dotnet new` command above is used to specify the name of the test project.
207+
# [NUnit](#tab/nunit)
208+
209+
```dotnetcli
210+
dotnet new bunit --framework nunit -o <NAME OF TEST PROJECT>
211+
```
212+
213+
# [MSTest](#tab/mstest)
214+
215+
```dotnetcli
216+
dotnet new bunit --framework mstest -o <NAME OF TEST PROJECT>
217+
```
218+
219+
***
220+
221+
The `--framework` option in the `dotnet new` command above is used to specify the unit testing framework used by the test project. If the `--framework` option is omitted, the default test framework `xunit` will be configured. Currently supported options are the following:
222+
223+
- `xunit` - [xUnit](https://xunit.net/),
224+
- `nunit` - [NUnit](https://nunit.org/),
225+
- `mstest` - [MSTest](https://docs.microsoft.com/en-us/dotnet/core/testing/unit-testing-with-mstest)
206226

207227
**3. Add the test project to your solution**
208228

0 commit comments

Comments
 (0)