bunit-test-migration

Migrate bUnit tests from beta-10 API to stable 2.x API.

Updated Oct 22, 2025
One-click install
npx skills add https://github.com/mpaulosky/ArticlesSite --skill bunit-test-migration-mpaulosky
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bunit-test-migration
Source: https://github.com/mpaulosky/ArticlesSite/tree/main/.github/skills/bunit-test-migration
Command: npx skills add https://github.com/mpaulosky/ArticlesSite --skill bunit-test-migration-mpaulosky

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers systematically migrate bUnit tests from deprecated 1.0.0-beta-10 APIs to the stable 2.x API, ensuring compatibility and long-term maintainability of Blazor tests.

Core Features & Use Cases

  • Migration rules: Update inheritance from TestComponentBase to BunitContext; remove Fixture wrappers; convert SnapshotTest blocks into [Fact] tests with Render and MarkupMatches; adjust test methods and naming conventions.
  • Guided refactoring: Provides examples and a complete migration workflow for single files or multiple test blocks.
  • Use Case: When updating a codebase that contains many .razor test files relying on legacy bUnit constructs (TestComponentBase, Fixture, SnapshotTest).

Quick Start

Open a legacy bUnit test file and apply the migration steps:

  1. Replace @inherits TestComponentBase with @inherits BunitContext.
  2. Remove <Fixture> wrappers and extract the inner component under test.
  3. Convert void TestMethod(Fixture fixture) to a public [Fact] method and rename to Component_Scenario_ExpectedResult.
  4. Replace fixture.GetComponentUnderTest() calls with Render(@<ComponentUnderTest />).
  5. Convert SnapshotTest blocks to [Fact] tests using Render and MarkupMatches. Then run dotnet test to verify.

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 the deprecated beta API to the stable 2.x version?

Migrate bUnit tests by replacing TestComponentBase inheritance with BunitContext, removing Fixture wrappers, converting SnapshotTest blocks to [Fact] methods with Render and MarkupMatches, and applying consistent naming conventions like Component_Scenario_ExpectedResult.

What is the replacement for the Fixture wrapper in bUnit 2.x test files?

In bUnit 2.x, Fixture wrappers are removed entirely. You extract the inner component under test and replace fixture.GetComponentUnderTest() calls with direct Render(@<ComponentUnderTest />) invocations within your [Fact] test methods.

Can I use this bUnit migration process on any Blazor test file?

This bUnit migration process applies specifically to .razor test files in Blazor projects. It targets files relying on legacy constructs like TestComponentBase, Fixture, or SnapshotTest from the deprecated 1.0.0-beta-10 API.

What's the best way to convert SnapshotTest blocks to the new bUnit 2.x API?

Convert SnapshotTest blocks into public [Fact] tests. Inside each method, use the Render method to render the component and assert the output using MarkupMatches to verify the rendered markup against the expected snapshot.

Why do my legacy bUnit test methods need signature and naming changes during migration?

Legacy bUnit test methods require signature changes to remove the Fixture parameter and adopt public [Fact] attributes. Naming conventions are standardized to Component_Scenario_ExpectedResult to ensure compatibility and maintainability with the 2.x API.