testGameWidget method
- @isTest
- String description, {
- WidgetSetupFunction<
T> ? setUp, - WidgetVerifyFunction<
T> ? verify, - bool? skip,
- Timeout? timeout,
- bool? semanticsEnabled,
- dynamic tags,
Creates a Game
specific test case with given description
which runs inside the Flutter test environment.
Use setUp
closure to prepare your game instance (e.g. add components to
it)
Use verify
closure to make verifications/assertions.
Implementation
@isTest
void testGameWidget(
String description, {
WidgetSetupFunction<T>? setUp,
WidgetVerifyFunction<T>? verify,
bool? skip,
Timeout? timeout,
bool? semanticsEnabled,
dynamic tags,
}) {
testWidgets(
description,
(tester) async {
final game = createGame();
await tester.runAsync(() async {
final gameWidget =
createGameWidget?.call(game) ?? GameWidget(game: game);
final pump = pumpWidget ??
(GameWidget<T> pumpWidget, WidgetTester tester) =>
tester.pumpWidget(pumpWidget);
await pump(gameWidget, tester);
await tester.pump();
if (setUp != null) {
await setUp.call(game, tester);
await tester.pump();
}
});
if (verify != null) {
await verify(game, tester);
}
},
skip: skip,
timeout: timeout,
semanticsEnabled: semanticsEnabled ?? true,
tags: tags,
);
}