toProcessPaper<U extends UnitWidget<Paper> , S extends UnitWidgetState<Paper, U> > static method
- @isTest
- String description, {
- required U create(),
- void setup(
- S state,
- AgentValidator agentValidator
- required Paper? paper,
- required void test(
- WidgetTester tester,
- S state,
- AgentValidator agentValidator
- bool? skip,
- Timeout? timeout,
- bool semanticsEnabled = true,
- TestVariant<
Object?> variant = const flutter_test.DefaultTestVariant(), - dynamic tags,
- int? retry,
- LeakTesting? experimentalLeakTesting,
Create a test to verify the operations when U
unit widget handles paper
with the given description
.
U
is type the of target unit. S
is the type of corresponding state of U
.
create
is the method to create the target unit widget.
The input s
is convenient for inject parent state to the widget.
setup
is for initializing and preparing required dependencies for target widget.
setup
is called at very first. setup
is optional.
paper
is the target paper need to test the operation of handling.
The testing will command the unit created to process paper
after setup
.
test
is the operation for verify the test case.
skip
is equivalent to skip
of testWidgets
in flutter_test.
timeout
is equivalent to timeout
of testWidgets
in flutter_test.
semanticsEnabled
is equivalent to semanticsEnabled
of testWidgets
in flutter_test.
variant
is equivalent to variant
of testWidgets
in flutter_test.
tags
is equivalent to tags
of testWidgets
in flutter_test.
retry
is equivalent to retry
of testWidgets
in flutter_test.
experimentalLeakTesting
is equivalent to experimentalLeakTesting
of testWidgets
in flutter_test.
Refer to TestUnitWidget for an example.
Implementation
@isTest
static void toProcessPaper<U extends UnitWidget<Paper>,
S extends UnitWidgetState<Paper, U>>(
String description, {
required U Function(UnitWidgetState s) create,
void Function(S state, AgentValidator agentValidator)? setup,
required Paper? paper,
required void Function(
flutter_test.WidgetTester tester,
S state,
AgentValidator agentValidator,
) test,
bool? skip,
flutter_test.Timeout? timeout,
bool semanticsEnabled = true,
flutter_test.TestVariant<Object?> variant =
const flutter_test.DefaultTestVariant(),
dynamic tags,
int? retry,
LeakTesting? experimentalLeakTesting,
}) {
final tester = UnitTestingEnvironment();
flutter_test.testWidgets(
description,
(flutter_test.WidgetTester widgetTester) async {
await widgetTester.runAsync(() async {
await tester.setupTestingUnitWidget(create, widgetTester);
final state = tester.context?.state;
final agentValidator = tester.network.agentValidator;
setup?.call(state, agentValidator);
if (paper != null) {
await tester.commandTestingUnit(paper);
}
test(widgetTester, state, agentValidator);
});
},
skip: skip,
timeout: timeout,
semanticsEnabled: semanticsEnabled,
variant: variant,
tags: tags,
retry: retry,
experimentalLeakTesting: experimentalLeakTesting,
);
}