.NET Tools
Essential productivity kit for .NET and game developers
OSS Power-Ups: bUnit – Webinar Recording
The recording of our webinar, OSS Power-Ups: bUnit, with Egil Hansen and Steven Giesel, is available. This was the twelfth episode of our OSS Power-Ups series, where we put a spotlight on open-source .NET projects. Subscribe to our community newsletter to receive notifications about future webinars.
In this talk, you will learn how to get started creating tests for your Blazor components using bUnit, in a way that feels almost like regular unit testing.
bUnit is a library you add to a regular .NET testing project, e.g., a xUnit test project, that allows you to render your component with minimal effort, inspect the produced markup after each render and interact with the component under test. There is no browser involved, headless or otherwise, which means tests run fast and are predictable, just like regular unit tests.
The talk will cover all the basics, from setting up a bUnit test project to writing tests that render and interact with Blazor components.
Webinar agenda:
- 00:00 – Welcome!
- 01:11 – About OSS PowerUps
- 03:21 – Hello, Egil and Steven!
- 09:37 – What is bUnit, and why is it necessary?
- 14:27 – Installing bUnit into a project
- 20:00 – Testing a Counter component
- 25:44 – Let’s make that test fail!
- 26:44 – About Speed, JavaScript, and end-to-end tests
- 32:24 – .NET CLI template (dotnet new)
- 33:00 – Mixed test flavors (Razor vs. C#)
- 36:02 – MarkupMatches assertions
- 40:07 – Cascading parameters in Razor tests
- 43:07 – What should you test?
- 47:55 – Cascading parameters in C# tests
- 52:02 – Razor compiler
- 53:35 – Injecting dependencies/services into components
- 55:38 – Stubbing components (e.g., third-party)
- 67:58 – Generation of stub classes (source generators?)
- 75:18 – Debugging
- 78:12 – Mocking JavaScript calls
- 84:30 – Outro
Resources:
About the presenter: