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
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
+95-22Lines changed: 95 additions & 22 deletions
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,7 +66,7 @@ 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 +85,7 @@ This will allow the test project to see and test the components in the component
84
85
85
86
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
87
87
-
1. Create a new xUnit/NUnit/MSTest testing project
88
+
1. Create a new xUnit/NUnit/MSTest/TUnit testing project
88
89
2. Add bUnit to the test project
89
90
3. Configure project settings
90
91
4. Add the test project to your existing solution
@@ -101,6 +102,12 @@ Use the following command (_click on the tab for the test framework of choice_):
101
102
dotnet new xunit -o <NAME OF TEST PROJECT>
102
103
```
103
104
105
+
# [xUnit v3](#tab/xunitv3)
106
+
107
+
```dotnetcli
108
+
dotnet new xunit3 -o <NAME OF TEST PROJECT>
109
+
```
110
+
104
111
# [NUnit](#tab/nunit)
105
112
106
113
```dotnetcli
@@ -113,6 +120,12 @@ dotnet new nunit -o <NAME OF TEST PROJECT>
113
120
dotnet new mstest -o <NAME OF TEST PROJECT>
114
121
```
115
122
123
+
# [TUnit](#tab/tunit)
124
+
125
+
```dotnetcli
126
+
dotnet new TUnit -o <NAME OF TEST PROJECT>
127
+
```
128
+
116
129
***
117
130
118
131
The `-o` option in the `dotnet new` command above is used to specify the name of the test project.
@@ -240,6 +308,11 @@ The result should be a test project with a `.csproj` that looks like this (non b
240
308
</Project>
241
309
```
242
310
311
+
> [!WARNING]
312
+
> **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
313
+
314
+
***
315
+
243
316
## Further reading
244
317
245
318
To start creating tests, continue reading the <xref:writing-tests> page.
Copy file name to clipboardExpand all lines: docs/site/index.md
+1-1Lines changed: 1 addition & 1 deletion
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