bunit-test-migration
Migrate bUnit test files from deprecated beta API (1.0.0-beta-10) to bUnit 2.x stable API. Use this when working on .razor test files in BlazorWebFormsComponents.Test that contain old patterns like TestComponentBase, Fixture, or SnapshotTest.
Installation
Pick a client and clone the repository into its skills directory.
Installation
About this skill
Migrate bUnit test files from deprecated beta API (1.0.0-beta-10) to bUnit 2.x stable API. Use this when working on .razor test files in BlazorWebFormsComponents.Test that contain old patterns like TestComponentBase, Fixture, or SnapshotTest.
How to use
Zidentyfikuj pliki testowe .razor w projekcie BlazorWebFormsComponents.Test, które zawierają stare wzorce: @inherits TestComponentBase, elementy
, , lub metody przyjmujące parametr Fixture. Zmień dziedziczenie klasy z TestComponentBase na BunitContext w dyrektywie @inherits na początku pliku.
Usuń elementy opakowujące
i ze swoich testów, zachowując tylko komponenty wewnątrz nich. Przekonwertuj stare metody testowe na nowy format: dodaj atrybut [Fact], zmień sygnaturę na public void, usuń parametr Fixture i zmień nazwę metody na wzór ComponentName_Scenario_ExpectedResult().
Zamień dostęp do komponentu z var cut = fixture.GetComponentUnderTest() na var cut = Render(@
), gdzie parametry dostosuj do Twojego komponentu. Przekonwertuj testy snapshot'ów: zamień elementy
, i na zwykłą metodę testową z atrybutem [Fact], która renderuje komponent i weryfikuje jego wyjście HTML.