bunit-test-migration

Migrate bUnit 1.x test patterns to the 2.x API in .razor files.

450|78|Updated Dec 3, 2019
One-click install
npx skills add https://github.com/FritzAndFriends/BlazorWebFormsComponents --skill bunit-test-migration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bunit-test-migration
Source: https://github.com/FritzAndFriends/BlazorWebFormsComponents/tree/main/.github/skills/bunit-test-migration
Command: npx skills add https://github.com/FritzAndFriends/BlazorWebFormsComponents --skill bunit-test-migration

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides developers in migrating bUnit tests from deprecated 1.0.0-beta-10 patterns to the stable bUnit 2.x API, reducing manual editing and ensuring tests run with the new rendering model.

Core Features & Use Cases

  • Inheritance migration: update @inherits TestComponentBase to @inherits BunitContext.
  • Remove wrapper elements: drop <Fixture> blocks and their wrappers.
  • Test method conversion: convert void TestName(Fixture fixture) to [Fact] public void TestName().
  • Render and verify: replace fixture.GetComponentUnderTest() patterns with Render(@<Component />) calls.
  • Snapshot tests: convert SnapshotTest blocks to [Fact] methods that use Render and MarkupMatches.

Quick Start

Review files with .razor test files using old patterns and apply the migration rules above. Then run tests to validate.

Frequently Asked Questions about bunit-test-migration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate bUnit tests from TestComponentBase and Fixture to the new API?

To migrate bUnit tests, update @inherits TestComponentBase to @inherits BunitContext, remove <Fixture> wrapper blocks, and convert test methods to standard [Fact] void signatures. This transitions legacy 1.x patterns to the modern bUnit 2.x rendering model.

What is the best way to convert bUnit SnapshotTest blocks to standard test methods?

Converting SnapshotTest blocks requires replacing them with [Fact] methods that use Render(@<Component />) calls to render the component. You then validate the output using MarkupMatches, adapting the legacy snapshot pattern to the modern bUnit 2.x API.

How do I replace GetComponentUnderTest with Render calls during a bUnit migration?

Replace fixture.GetComponentUnderTest() patterns by calling Render(@<Component />) directly within your [Fact] test methods. This updates the component rendering logic to match the modern bUnit 2.x API requirements.

Does the bUnit 2.x migration apply to all my Blazor .razor test files?

The migration applies to .razor test files within BlazorWebFormsComponents.Test that use legacy patterns like TestComponentBase, Fixture, or SnapshotTest. It targets upgrading these specific files to the stable bUnit 2.x API.

Why are my bUnit tests failing after upgrading from 1.x beta patterns?

Tests fail because the bUnit 2.x API removed legacy TestComponentBase and Fixture wrappers. You must update inheritance to BunitContext, remove Fixture blocks, and convert SnapshotTest blocks to [Fact] methods to resolve the rendering errors.

Can I automate updating void TestName(Fixture fixture) signatures to [Fact] public void TestName()?

Yes, migrating legacy bUnit tests applies rules to automatically convert void TestName(Fixture fixture) signatures into [Fact] public void TestName() methods. This removes the Fixture parameter dependency required by the old 1.x API.