GitPedia

BUnit

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.

From bUnit-dev·Updated June 26, 2026·View on GitHub·

**bUnit** is a testing library for Blazor Components. Its goal is to make it easy to write _comprehensive, stable_ unit tests. With bUnit, you can: The project is written primarily in C#, distributed under the MIT License license, first published in 2019. It has gained significant community traction with 1,296 stars and 119 forks on GitHub. Key topics include: blazor, blazor-components, bunit, cascading-values, component-testing.

Latest release: v2.7.22.7.2
March 31, 2026View Changelog →

GitHub tag
Nuget
Issues Open

bUnit - a testing library for Blazor components

bUnit is a testing library for Blazor Components. Its goal is to make it easy to write comprehensive, 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 to bUnit.dev to learn more.

NuGet Downloads

bUnit is available on NuGet in various incarnations. Most should just pick the bUnit package:

NameDescriptionNuGet Download Link
bUnitAdds support for testing Blazor components.Nuget
bUnit.templateTemplate, which currently creates xUnit-based bUnit test projects only.Nuget
bUnit.generatorsSource code generators to minimize code setup in various situations.Nuget
bUnit.web.querybUnit implementation of testing-library.com's query APIs.Nuget

To get started, head to the getting started documentation to learn more.

bUnit and .NET version compatibility matrix

bUnit version.NET version
1.x≥ .netcore3.1 && ≤ .net 9
2.x≥ .net8

For a migration guide, see Upgrading bUnit.

Sponsors

A huge thank you to the sponsors of bUnit. The higher tier sponsors are:

<table border="0"> <tr> <td align="center" width="250"> <a href="https://www.testmuai.com/?utm_medium=sponsor&utm_source=bunit" target="_blank"> <img src="docs/site/sponsors/testmu.png" style="vertical-align: middle;" width="250" height="45" /> <br /> TestMu AI </a> </td> </tr> </table>

Contributors

Shout outs and a big thank you to 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:

<a href="https://github.com/bUnit-dev/bUnit/graphs/contributors"> <img src="https://contrib.rocks/image?repo=bUnit-dev/bUnit" /> </a>

Code of conduct

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.

.NET Foundation

This project is supported by the .NET Foundation.

Contributors

Showing top 12 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from bUnit-dev/bUnit via the GitHub API.Last fetched: 6/28/2026