ワンクリックで
statera-tests
Patterns and guidelines for writing widget tests. Use these instructions when asked to create tests for a Flutter widget.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Patterns and guidelines for writing widget tests. Use these instructions when asked to create tests for a Flutter widget.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | statera-tests |
| description | Patterns and guidelines for writing widget tests. Use these instructions when asked to create tests for a Flutter widget. |
use customPump() from test/helpers.dart to pump a widget under test.
pass any providers (including Cubits/Blocs) via extraProviders.
stub/mock only the required dependencies of the widget under test. The test should fail if any mock is removed.
for BlocListener-driven widgets, stub state and/or stream depending on what is being used in the widget:
when(cubit.state).thenReturn(SomeState());
when(cubit.stream).thenAnswer((_) => Stream.value(SomeState()));
mocks are generated by Mockito — each service class has @GenerateNiceMocks([MockSpec<T>()]) on it and a corresponding .mocks.dart file. After adding a new mock annotation, regenerate with dart run build_runner build.
BLoC-unit tests use the bloc_test package (blocTest<>, seed:, act:, expect:).
always extract a helper method that pumps the widget under test, it should be named pump[WidgetName].
place helper methods AFTER all the tests in the test file.