testWidgetModel<WM extends WidgetModel<ElementaryWidget<IWidgetModel> , ElementaryModel> , W extends ElementaryWidget<IWidgetModel> > function
- @isTest
Testing function for test WidgetModel.
description
- description of test.
setupWm
- function should return wm that will be test.
testFunction
- function that test wm.
skip
- should skip the test. If passed a String or true
, the test is
skipped. If it's a String, it should explain why the test is skipped;
this reason will be printed instead of running the test.
If timeout
is passed, it's used to modify or replace the default timeout
of 30 seconds. Timeout modifications take precedence in suite-group-test
order, so timeout
will also modify any timeouts set on the group or suite.
The description will be added to the descriptions of any surrounding
groups. If testOn
is passed, it's parsed as a platform selector
; the
test will only be run on matching platforms.
If tags
is passed, it declares user-defined tags that are applied to the
test. These tags can be used to select or skip the test on the command line,
or to do bulk test configuration. All tags should be declared in the
configuring tags
. The parameter can be an
Iterable of tag names, or a String representing a single tag.
onPlatform
allows tests to be configured on a platform-by-platform
basis. It's a map from strings that are parsed as PlatformSelectors to
annotation classes: Timeout, Skip, or lists of those. These
annotations apply only on the given platforms.
If retry
is passed, the test will be retried the provided number of times
before being marked as a failure.
Implementation
@isTest
void testWidgetModel<WM extends WidgetModel, W extends ElementaryWidget>(
String description,
WM Function() setupWm,
dynamic Function(WM wm, WMTester<WM, W> tester, WMContext context)
testFunction, {
String? testOn,
Timeout? timeout,
// ignore: avoid_annotating_with_dynamic
dynamic skip,
// ignore: avoid_annotating_with_dynamic
dynamic tags,
Map<String, dynamic>? onPlatform,
int? retry,
}) {
setUp(() {
registerFallbackValue(WMContext());
});
test(
description,
() async {
final wm = setupWm();
final element = _WMTestableElement<WM, W>(wm);
await testFunction(wm, element, element);
},
testOn: testOn,
timeout: timeout,
skip: skip,
tags: tags,
onPlatform: onPlatform,
retry: retry,
);
}