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-1
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
+99-22
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,23 +43,34 @@ 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
61
62
dotnet new bunit --framework mstest -o <NAME OF TEST PROJECT>
62
63
```
63
64
65
+
# [TUnit](#tab/tunit)
66
+
67
+
There is no prebuilt template for **TUnit**. More information on how to set up a **TUnit** project can be found down below.
68
+
64
69
***
65
70
66
71
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 +89,7 @@ This will allow the test project to see and test the components in the component
84
89
85
90
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
91
87
-
1. Create a new xUnit/NUnit/MSTest testing project
92
+
1. Create a new xUnit/NUnit/MSTest/TUnit testing project
88
93
2. Add bUnit to the test project
89
94
3. Configure project settings
90
95
4. Add the test project to your existing solution
@@ -101,6 +106,12 @@ Use the following command (_click on the tab for the test framework of choice_):
101
106
dotnet new xunit -o <NAME OF TEST PROJECT>
102
107
```
103
108
109
+
# [xUnit v3](#tab/xunitv3)
110
+
111
+
```dotnetcli
112
+
dotnet new xunit3 -o <NAME OF TEST PROJECT>
113
+
```
114
+
104
115
# [NUnit](#tab/nunit)
105
116
106
117
```dotnetcli
@@ -113,6 +124,12 @@ dotnet new nunit -o <NAME OF TEST PROJECT>
113
124
dotnet new mstest -o <NAME OF TEST PROJECT>
114
125
```
115
126
127
+
# [TUnit](#tab/tunit)
128
+
129
+
```dotnetcli
130
+
dotnet new TUnit -o <NAME OF TEST PROJECT>
131
+
```
132
+
116
133
***
117
134
118
135
The `-o` option in the `dotnet new` command above is used to specify the name of the test project.
<ProjectReferenceInclude="<PATH TO COMPONENT LIB>.csproj" />
310
+
</ItemGroup>
311
+
312
+
</Project>
313
+
```
314
+
315
+
> [!WARNING]
316
+
> **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
317
+
318
+
***
319
+
243
320
## Further reading
244
321
245
322
To start creating tests, continue reading the <xref:writing-tests> page.
Copy file name to clipboardExpand all lines: docs/site/index.md
+1-1
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.**
0 commit comments