bunit 2.4.2

Prefix Reserved
dotnet add package bunit --version 2.4.2
                    
NuGet\Install-Package bunit -Version 2.4.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="bunit" Version="2.4.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="bunit" Version="2.4.2" />
                    
Directory.Packages.props
<PackageReference Include="bunit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add bunit --version 2.4.2
                    
#r "nuget: bunit, 2.4.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package bunit@2.4.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=bunit&version=2.4.2
                    
Install as a Cake Addin
#tool nuget:?package=bunit&version=2.4.2
                    
Install as a Cake Tool

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:

Name Description NuGet Download Link
bUnit Adds support for testing Blazor components. Nuget
bUnit.template Template, which currently creates xUnit-based bUnit test projects only. Nuget
bUnit.generators Source code generators to minimize code setup in various situations. Nuget
bUnit.web.query bUnit 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.lambdatest.com/?utm_source=bunit&utm_medium=sponsor" target="_blank"> <img src="https://www.lambdatest.com/blue-logo.png" style="vertical-align: middle;" width="250" height="45" /> <br /> LambdaTest </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.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (24)

Showing the top 5 NuGet packages that depend on bunit:

Package Downloads
Verify.Bunit

Extends Verify (https://github.com/VerifyTests/Verify) to allow Blazor component verification via BUnit.

Blazored.Toast.TestExtensions

A testing library to provide helper extensions for Blazored.Toast

FluentAssertions.BUnit

Extension methods that provide fluent assertions on top of BUnit.

bunit.web.query

bunit.web.query is an experimental package that provides an bUnit version of the https://testing-library.com/ APIs.

StoicDreams.TestFramework.Blazor

Extended functionality of Stoic Dreams Test Framework, adding funtionality to handle testing against rendered .razor components for unit and integration testing.

GitHub repositories (38)

Showing the top 20 popular GitHub repositories that depend on bunit:

Repository Stars
MudBlazor/MudBlazor
Blazor Component Library based on Material Design principles with an emphasis on ease of use and extensibility
ServiceStack/ServiceStack
Thoughtfully architected, obscenely fast, thoroughly enjoyable web services for all
dotnet/aspire
Aspire is the tool for code-first, extensible, observable dev and deploy.
microsoft/fluentui-blazor
Microsoft Fluent UI Blazor components library. For use with ASP.NET Core Blazor applications
dotnetcore/BootstrapBlazor
Bootstrap Blazor is an enterprise-level UI component library based on Bootstrap and Blazor.
Megabit/Blazorise
Blazorise is a component library built on top of Blazor with support for CSS frameworks like Bootstrap, Tailwind, Bulma, AntDesign, and Material.
Blazor-Diagrams/Blazor.Diagrams
A fully customizable and extensible all-purpose diagrams library for Blazor
masastack/MASA.Blazor
Blazor UI component library based on Material Design. Support Blazor Server, Blazor WebAssembly and MAUI Blazor.
abpframework/abp-samples
Sample solutions built with the ABP Framework
CodeMazeBlog/CodeMazeGuides
The main repository for all the Code Maze guides
runceel/ReactiveProperty
ReactiveProperty provides MVVM and asynchronous support features under Reactive Extensions. Target frameworks are .NET 6+, .NET Framework 4.7.2 and .NET Standard 2.0.
Azure-Samples/azure-search-openai-demo-csharp
A sample app for the Retrieval-Augmented Generation pattern running in Azure, using Azure Cognitive Search for retrieval and Azure OpenAI large language models to power ChatGPT-style and Q&A experiences.
meziantou/Meziantou.Framework
Aguafrommars/TheIdServer
OpenID/Connect, OAuth2, WS-Federation and SAML 2.0 server based on Duende IdentityServer and ITFoxtec Identity SAML 2.0 with its admin UI
Blazored/Toast
A JavaScript free toast library for Blazor and Razor Component applications
Blazored/FluentValidation
A library for using FluentValidation with Blazor
CodeBeamOrg/CodeBeam.MudBlazor.Extensions
Useful third party extension components for MudBlazor, from the contributors.
LumexUI/lumexui
🚀 A versatile Blazor UI library built using Tailwind CSS.
jsakamoto/BlazingStory
The clone of "Storybook" for Blazor, a frontend workshop for building UI components and pages in isolation.
linkdotnet/Blog
A blog (engine) completely written in C# and Blazor. It aims to be a simple use and easy to extend platform. Blogposts are written in Markdown and are rendered to HTML. This gives all the flexibility needed to express yourself but also have an easy way of creating posts in the first place.
Version Downloads Last Updated
2.4.2 3,178 12/21/2025
2.3.4 5,999 12/18/2025
2.3.3-preview 326 12/16/2025
2.2.2 33,981 12/8/2025
2.1.1 48,053 11/21/2025
2.0.66 36,481 11/11/2025
2.0.64-preview 1,387 10/31/2025
2.0.62-preview 1,227 10/19/2025
2.0.57-preview 253 10/17/2025
2.0.55-preview 1,091 10/7/2025
2.0.50-preview 6,413 9/12/2025
2.0.49-preview 690 8/30/2025
2.0.47-preview 262 8/30/2025
2.0.41-preview 12,171 6/27/2025
2.0.36-preview 76,414 2/21/2025
2.0.33-preview 37,339 7/21/2024
2.0.24-preview 46,574 3/13/2024
2.0.22-preview 2,147 3/9/2024
1.40.0 713,584 6/14/2025
1.39.5 399,556 4/4/2025
1.38.5 577,030 1/12/2025
1.37.7 126,159 12/13/2024
1.36.0 378,967 11/12/2024
1.35.3 11,087 11/12/2024
1.34.0 155,308 11/1/2024
1.33.3 222,475 10/11/2024
1.33.1-preview 347 10/7/2024
1.32.7 72,140 10/4/2024
1.31.3 330,682 8/16/2024
1.31.1-preview 404 8/14/2024
1.30.3 125,031 7/21/2024
1.29.5 96,572 7/5/2024
1.28.9 561,292 4/19/2024
1.28.4-preview 893 3/17/2024
1.28.2-preview 986 3/6/2024
1.27.17 328,402 3/2/2024
1.27.16-preview 892 3/2/2024
1.27.12-preview 1,651 2/23/2024
1.27.11-preview 1,346 2/19/2024
1.27.5-preview 12,059 1/9/2024
1.27.2-preview 1,730 12/28/2023
1.27.1-preview 1,625 12/28/2023
1.26.64 676,378 12/20/2023
1.26.61-preview.g17cfa782a0 418 12/17/2023
1.26.61-preview 1,542 12/17/2023
1.26.29-preview.ga9c0cd8510 454 12/12/2023
1.26.29-preview.g9431b069b0 364 12/12/2023
1.26.29-preview.g91e9e2287f 388 12/10/2023
1.26.29-preview.g6269f42046 331 12/12/2023
1.26.29-preview.g1595589333 335 12/13/2023
1.26.28-preview.g08ea910651 356 12/10/2023
1.26.27-preview.geb23ca9882 359 12/8/2023
1.26.27-preview.ge5c30f7b82 345 12/8/2023
1.26.26-preview.g3fdaceb6d0 1,036 11/25/2023
1.26.25-preview.gf8662d54ff 341 11/25/2023
1.26.25-preview.ga796d3d959 331 11/25/2023
1.26.25-preview.g43750dfc46 336 11/25/2023
1.26.25-preview.g028ac0e5cc 331 11/25/2023
1.26.24-preview.ge6af60b555 339 11/24/2023
1.26.23-preview 1,772 11/24/2023
1.26.20-preview 1,486 11/24/2023
1.26.19-preview 1,439 11/24/2023
1.26.18-preview 1,565 11/24/2023
1.26.17-preview 1,374 11/23/2023
1.26.4-preview 2,526 11/20/2023
1.26.1-preview 1,569 11/17/2023
1.25.3 260,721 11/14/2023
1.25.2-preview 2,554 11/13/2023
1.25.1-preview 28,459 10/21/2023
1.25.0-preview 1,842 10/21/2023
1.24.10 173,998 10/14/2023
1.24.9-preview 1,600 10/14/2023
1.24.8-preview 1,830 10/14/2023
1.24.3-preview 2,197 10/6/2023
1.23.9 147,449 9/6/2023
1.23.8-preview 1,771 9/5/2023
1.23.3-preview 2,563 8/23/2023
1.23.1-preview 2,841 7/31/2023
1.22.19 185,760 7/28/2023
1.22.18-preview 2,689 7/23/2023
1.22.16-preview 2,075 7/15/2023
1.22.15-preview 1,681 7/14/2023
1.22.14-preview 1,640 7/13/2023
1.22.13-preview 1,681 7/12/2023
1.22.7-preview 9,814 7/3/2023
1.21.14-preview 1,746 7/1/2023
1.21.9 97,230 7/2/2023 1.21.9 is deprecated because it has critical bugs.
1.21.8-preview 1,829 6/30/2023
1.21.7-preview 1,694 6/29/2023
1.21.5-preview 1,528 6/28/2023
1.21.3-preview 1,837 6/25/2023
1.20.8 147,093 5/21/2023 1.20.8 is deprecated because it has critical bugs.
1.20.7-preview 1,823 5/17/2023
1.19.14 166,009 4/26/2023 1.19.14 is deprecated because it has critical bugs.
1.18.4 638,383 2/26/2023
1.17.2 30,709 2/22/2023
1.16.2 121,168 2/7/2023
1.15.5 31,528 2/4/2023
1.14.4 137,966 1/11/2023
1.13.5 122,730 12/16/2022
1.12.6 294,988 11/8/2022
1.12.4-preview 2,310 10/26/2022
1.11.7 98,025 10/13/2022
1.10.14 116,586 9/16/2022
1.10.13-preview 1,851 9/16/2022
1.9.8 412,258 6/7/2022
1.9.7-preview 3,540 5/26/2022
1.9.1-preview 2,341 5/21/2022
1.8.15 64,958 5/19/2022
1.7.7 71,215 4/29/2022
1.6.4 362,938 2/22/2022
1.5.12 30,960 2/15/2022
1.4.15 210,101 12/18/2021
1.3.42 162,528 11/9/2021
1.3.38-preview 1,960 11/9/2021
1.3.35-preview 19,581 10/20/2021
1.3.30-preview 3,431 10/15/2021
1.2.49 186,258 8/9/2021
1.2.49-preview 2,309 8/7/2021
1.2.36-preview 6,741 6/25/2021
1.2.35-preview 1,830 6/24/2021
1.2.28-preview 3,694 5/26/2021
1.2.27-preview 1,990 5/22/2021
1.2.26-preview.gd07edb4207 540 5/21/2021
1.1.5 261,977 4/30/2021
1.0.19 35,539 4/11/2021
1.0.16 9,345 4/11/2021
1.0.0-preview-02 4,046 3/26/2021
1.0.0-preview-01 60,651 12/24/2020
1.0.0-beta-11 40,784 10/26/2020
1.0.0-beta-10 34,587 9/15/2020

Changes in bUnit 2.4.2

### Fixed

- Use proper return typed for `InputAsync` and `ChangeAsync` methods.

See the full changelog at https://github.com/bUnit-dev/bUnit/releases