-
Notifications
You must be signed in to change notification settings - Fork 30.6k
WidgetTester.tap() to stop ignoring failure #88759
Copy link
Copy link
Open
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projecta: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterf: integration_testThe flutter/packages/integration_test pluginThe flutter/packages/integration_test pluginframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projecta: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterf: integration_testThe flutter/packages/integration_test pluginThe flutter/packages/integration_test pluginframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Type
Fields
Give feedbackNo fields configured for issues without a type.
Use case
Most mobile apps use tapping as the primary interaction method. App tests must use
WidgetTester.tap()which is inherited fromWidgetController.tap(). Whentap()fails to find the target widget, it ignores this and continues. Failing to tap puts the app into an unintended state.In the best case the test detects this problem and fails later. Then the engineer must waste time back-tracking to find out why the test failed.
In the worst case, the test silently does not test the behavior it is designed to test. Then bugs end up in production and users suffer and the business loses money.
When
tap()fails to tap, it prints out a warning. Such warnings are easily missed in long test logs. This is especially true when logs include print-debugging (#88756).tap()takes an optional kwarg to suppress the warning.Proposal
tap()totryTap()and make it returntruewhen it successfully tapped.tap()function that instantly fails the test if it cannot perform its intended purpose.