Razor component testing using bUnit
In .NET MAUI development, we don’t really have a good unit test framework for XAML-based UI components, but we do have one for Blazor. bUnit is an excellent test library that can be used for the unit test development of Razor components. With the bUnit library, we can develop unit test cases for Razor components using xUnit, NUnit, or MSTest. We will use xUnit with bUnit for the rest of the chapter. The structure of unit test cases using bUnit is similar to the xUnit test cases that we introduced in the previous section.
The test targets in the rest of this chapter are the following Razor components that we created in the second part of this book:
- Razor components in the
PassXYZ.BlazorUI
project - Razor components in the
PassXYZ.Vault
project
To test Razor components using bUnit, we need to change the project configuration of PassXYZ.Vault.Tests
.
Changing project configuration for bUnit
To set up the test environment...