~/talk

Best practices unit testing Blazor components with bUnit

Talkat NDC Oslo 2021 · 2021-11-29..12-03· [dotnet, testing]
slides:none on file

bUnit is a testing library layered on xUnit/NUnit that renders Blazor components with the real renderer but no browser or JS, so tests run in milliseconds and can inspect the AngleSharp DOM and component instances. It provides event triggers, lifecycle emulation, semantic markup comparison (markupMatches with regex/ignore modifiers), and component substitution via factories/Stop<T> plus mocking (Moq) for isolating children. Example: a dynamic data table is refactored into header/row components and verified for composition, markup and data passing; tests remain stable and maintainable.

AI-written summary · about

  1. 0:00Intro
  2. 3:11What is bonit?
  3. 9:12The Counter component
  4. 9:30Test of component
  5. 12:33Running Unit tests
  6. 13:24Functionality testing - configure pizza dialog
  7. 16:16To verifying markup, do it semantically!
  8. 17:36Semantically verifying markup
  9. 18:29Semantic verification modifiers
  10. 20:18Creating testable and maintainable components
  11. 22:05Dynamic component example
  12. 28:40Creating maintainable tests
  13. 37:03Summary -testing
  14. 37:59Isolating the component under test
  15. 41:54Rules for substitute components
  16. 43:28Substitution with the built-in Stub component
  17. 46:39Mocking components
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.