runTest method
- Future<
void> testBody(), - VoidCallback invariantTester, {
- String description = '',
- @Deprecated('This parameter has no effect. Use the `timeout` parameter on `testWidgets` instead. ' 'This feature was deprecated after v2.6.0-1.0.pre.') Duration? timeout,
Call the testBody inside a FakeAsync scope on which pump can advance time.
Returns a future which completes when the test has run.
Called by the testWidgets and benchmarkWidgets functions to run a test.
The invariantTester argument is called inside this method immediately
after the testBody completes and the widget tree is unmounted (for
example, to verify that tickers and semantics handles were disposed).
This should not be confused with framework-level invariant checks (such as
verifying that debug flags were reset and pending timers disposed) and
binding state cleanups, which are performed in postTest after the
Future returned by this method completes and after any per-test
addTearDown callbacks have executed.
The description is used by the LiveTestWidgetsFlutterBinding to
show a label on the screen during the test. The description comes from
the value passed to testWidgets.
Implementation
@override
Future<void> runTest(
Future<void> Function() testBody,
VoidCallback invariantTester, {
String description = '',
@Deprecated(
'This parameter has no effect. Use the `timeout` parameter on `testWidgets` instead. '
'This feature was deprecated after v2.6.0-1.0.pre.',
)
Duration? timeout,
}) async {
await super.runTest(testBody, invariantTester, description: description);
results[description] ??= _success;
}