You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@
12
12
- Pass parameters, cascading values and inject services into components under test
13
13
- Mock `IJSRuntime`, Blazor authentication and authorization, and others
14
14
15
-
bUnit builds on top of existing unit testing frameworks such as xUnit, NUnit, and MSTest, which run the Blazor component tests in just the same way as any normal unit test. bUnit runs a test in milliseconds, compared to browser-based UI tests which usually take seconds to run.
15
+
bUnit builds on top of existing unit testing frameworks such as xUnit, NUnit, MSTest and TUnit, which run the Blazor component tests in just the same way as any normal unit test. bUnit runs a test in milliseconds, compared to browser-based UI tests which usually take seconds to run.
16
16
17
17
**Go to [bUnit.dev](https://bunit.dev) to learn more.**
Copy file name to clipboardExpand all lines: docs/site/docs/getting-started/create-test-project.md
+90-22Lines changed: 90 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,12 +25,6 @@ These steps look like this from the `dotnet` CLI:
25
25
26
26
Install the template from NuGet using this command:
27
27
28
-
```dotnetcli
29
-
dotnet new --install bunit.template
30
-
```
31
-
32
-
Or, since .NET 7 onwards:
33
-
34
28
```dotnetcli
35
29
dotnet new install bunit.template
36
30
```
@@ -49,12 +43,19 @@ the framework of your choice:
49
43
dotnet new bunit --framework xunit -o <NAME OF TEST PROJECT>
50
44
```
51
45
46
+
# [xUnit v3](#tab/xunitv3)
47
+
48
+
```dotnetcli
49
+
dotnet new bunit --framework xunitv3 -o <NAME OF TEST PROJECT>
50
+
```
51
+
52
52
# [NUnit](#tab/nunit)
53
53
54
54
```dotnetcli
55
55
dotnet new bunit --framework nunit -o <NAME OF TEST PROJECT>
56
56
```
57
57
58
+
58
59
# [MSTest](#tab/mstest)
59
60
60
61
```dotnetcli
@@ -65,9 +66,10 @@ dotnet new bunit --framework mstest -o <NAME OF TEST PROJECT>
65
66
66
67
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:
@@ -84,7 +86,7 @@ This will allow the test project to see and test the components in the component
84
86
85
87
This section will take you through the steps required to create a project for testing Blazor components using bUnit. Any of the three general-purpose test frameworks shown in step 1 below can be used. Briefly, here is what we will do:
86
88
87
-
1. Create a new xUnit/NUnit/MSTest testing project
89
+
1. Create a new xUnit/NUnit/MSTest/TUnit testing project
88
90
2. Add bUnit to the test project
89
91
3. Configure project settings
90
92
4. Add the test project to your existing solution
@@ -101,6 +103,12 @@ Use the following command (_click on the tab for the test framework of choice_):
@@ -240,6 +303,11 @@ The result should be a test project with a `.csproj` that looks like this (non b
240
303
</Project>
241
304
```
242
305
306
+
> [!WARNING]
307
+
> **TUnit** and the `Microsoft.NET.Sdk.Razor` both utilize source code generators. Source generators can not see or interact with the output of another generator. Therefore **TUnit** does not work with `razor` files. Using `cs` based tests is working perfectly fine. For more information regarding the setup of **TUnit** head over to: https://github.com/thomhurst/TUnit
308
+
309
+
***
310
+
243
311
## Further reading
244
312
245
313
To start creating tests, continue reading the <xref:writing-tests> page.
Copy file name to clipboardExpand all lines: docs/site/index.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ title: bUnit - a testing library for Blazor components
17
17
- Pass parameters, cascading values and inject services into components under test
18
18
- Mock `IJSRuntime`, Blazor authentication and authorization, and others
19
19
20
-
bUnit builds on top of existing unit testing frameworks such as xUnit, NUnit, and MSTest, which run the Blazor components tests in just the same way as any normal unit test. bUnit runs a test in milliseconds, compared to browser-based UI tests which usually take seconds to run.
20
+
bUnit builds on top of existing unit testing frameworks such as xUnit, NUnit, MSTest and TUnit, which run the Blazor components tests in just the same way as any normal unit test. bUnit runs a test in milliseconds, compared to browser-based UI tests which usually take seconds to run.
21
21
22
22
**Go to the [Documentation](xref:getting-started) pages to learn more.**
23
23
@@ -44,7 +44,7 @@ bUnit is available on NuGet in various incarnations. Most users should just pick
44
44
|[bUnit](https://www.nuget.org/packages/bunit/)| Includes the bUnit.core and bUnit.web packages. |[](https://www.nuget.org/packages/bunit/)|
45
45
|[bUnit.core](https://www.nuget.org/packages/bunit.core/)| Core library that enables rendering a Blazor component in a test context. |[](https://www.nuget.org/packages/bunit.core/)|
46
46
|[bUnit.web](https://www.nuget.org/packages/bunit.web/)| Adds support for testing Blazor components for the web. This includes bUnit.core. |[](https://www.nuget.org/packages/bunit.web/)|
47
-
|[bUnit.template](https://www.nuget.org/packages/bunit.template/)| Template for bUnit test projects based on xUnit, NUnitor MSTest|[](https://www.nuget.org/packages/bunit.template/)|
47
+
|[bUnit.template](https://www.nuget.org/packages/bunit.template/)| Template for bUnit test projects based on xUnit, NUnit, MSTest or TUnit|[](https://www.nuget.org/packages/bunit.template/)|
48
48
|[bUnit.generators](https://www.nuget.org/packages/bunit.generators/)|Source code generators to minimize code setup in various situations.|[](https://www.nuget.org/packages/bunit.generators/)|
49
49
|[bUnit.web.query](https://www.nuget.org/packages/bunit.web.query/)|bUnit implementation of testing-library.com's query APIs.|[](https://www.nuget.org/packages/bunit.web.query/)|
0 commit comments