Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork116
bUnit is a testing library for Blazor components that make tests look, feel, and runs like regular unit tests. bUnit makes it easy to render and control a component under test’s life-cycle, pass parameter and inject services into it, trigger event handlers, and verify the rendered markup from the component using a built-in semantic HTML comparer.
License
bUnit-dev/bUnit
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
bUnit is a testing library for Blazor Components. Its goal is to make it easy to writecomprehensive, stable unit tests. With bUnit, you can:
- Setup and define components under tests using C# or Razor syntax
- Verify outcomes using semantic HTML comparer
- Interact with and inspect components as well as trigger event handlers
- Pass parameters, cascading values and inject services into components under test
- Mock
IJSRuntime, Blazor authentication and authorization, and others
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.
Go tobUnit.dev to learn more.
bUnit is available on NuGet in various incarnations. Most should just pick thebUnit package:
| Name | Description | NuGet Download Link |
|---|---|---|
| bUnit | Adds support for testing Blazor components. | |
| bUnit.template | Template, which currently creates xUnit-based bUnit test projects only. | |
| bUnit.generators | Source code generators to minimize code setup in various situations. | |
| bUnit.web.query | bUnit implementation of testing-library.com's query APIs. |
To get started, head to thegetting started documentation to learn more.
| bUnit version | .NET version |
|---|---|
| 1.x | ≥ .netcore3.1 && ≤ .net 9 |
| 2.x | ≥ .net8 |
For a migration guide, seeUpgrading bUnit.
A huge thank you to thesponsors of bUnit. The higher tier sponsors are:
![]() LambdaTest |
Shout outs and a big thank youto all the contributors to the library, including those that raise issues, provide input to issues, and those who send pull requests. Thank you!
These good people have contributed code or documentation to bUnit:
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community.For more information see the.NET Foundation Code of Conduct.
This project is supported by the.NET Foundation.
About
bUnit is a testing library for Blazor components that make tests look, feel, and runs like regular unit tests. bUnit makes it easy to render and control a component under test’s life-cycle, pass parameter and inject services into it, trigger event handlers, and verify the rendered markup from the component using a built-in semantic HTML comparer.
Topics
Resources
License
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
