Skip to content

Conversation

@kevmoo
Copy link
Contributor

@kevmoo kevmoo commented Jun 19, 2025

Mostly related to error tracking.

Mostly related to error tracking.
@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. f: cupertino flutter/packages/flutter/cupertino repository f: routes Navigator, Router, and related APIs. labels Jun 19, 2025
try {
await tester.binding.defaultBinaryMessenger.handlePlatformMessage(

await tester.binding.defaultBinaryMessenger.handlePlatformMessage(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SO MANY of these.

Just run the code. If it fails, the test will fail.

What do we get by catching and checking for a null error?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you by looking at this code. I'm trying to think of a benefit of try/catch but not seeing it.

@Renzo-Olivares do you remember why you wrote the test this way in #168678? Is it relevant that you pumpAndSettle before checking error?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One argument is that this communicates the intent of the test author that this specific code should not throw an error. If these lines are broken in the future so that they do throw an error, someone might think that the test was poorly written and update the test to work around the error, rather than realizing that the test is explicitly written to ensure that this code does not throw an error.

Maybe this problem is more elegantly solved with a simple comment though!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my notes in the doc...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I was trying to communicate anything by using a try/catch block here. I most likely just pulled this from another test. Makes sense to remove it.

final dynamic exception = tester.takeException();
expect(exception, isNotNull);
expect(exception, isFlutterError);
final FlutterError error = exception as FlutterError;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line will throw with a helpful error. No reason to do these extra checks, right?

Object? error;
try {
await tester.pumpWidget(
await expectLater(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MUCH cleaner

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, it's also more precise by using throwsAssertionError instead of isNotNull. I will use this pattern in the future if it comes up 👍 .

@kevmoo kevmoo marked this pull request as ready for review June 20, 2025 16:45
@kevmoo kevmoo requested a review from justinmc June 20, 2025 16:45
@kevmoo
Copy link
Contributor Author

kevmoo commented Jun 20, 2025

If there are reasons that these tests shouldn't be simplified, I'd love to know!

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I also want to hear from @Renzo-Olivares in case he has any opinions.

I gave some thoughts in the comments below. One other point I wanted to make is that the cases that use takeException can affect control flow.

throw FlutterError('fail');

expect(thing, isTrue); // Never executed.
await tester.pumpWidgets(<widget tree that produces an exception>);

expect(thing, isTrue); // Still executed!
await tester.pumpWidgets(<widget tree that produces an exception>);

expect(tester.takeException(), isNull); // Fails here.

expect(thing, isTrue); // Not executed.

However, I don't think this has any notable implications on the tests that were changed in this PR.

try {
await tester.binding.defaultBinaryMessenger.handlePlatformMessage(

await tester.binding.defaultBinaryMessenger.handlePlatformMessage(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you by looking at this code. I'm trying to think of a benefit of try/catch but not seeing it.

@Renzo-Olivares do you remember why you wrote the test this way in #168678? Is it relevant that you pumpAndSettle before checking error?

try {
await tester.binding.defaultBinaryMessenger.handlePlatformMessage(

await tester.binding.defaultBinaryMessenger.handlePlatformMessage(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One argument is that this communicates the intent of the test author that this specific code should not throw an error. If these lines are broken in the future so that they do throw an error, someone might think that the test was poorly written and update the test to work around the error, rather than realizing that the test is explicitly written to ensure that this code does not throw an error.

Maybe this problem is more elegantly solved with a simple comment though!

Object? error;
try {
await tester.pumpWidget(
await expectLater(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, it's also more precise by using throwsAssertionError instead of isNotNull. I will use this pattern in the future if it comes up 👍 .

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renewing my LGTM.

The lesson here seems to be:

// Bad:
AssertionError? error;
 try {
   myTestCode();
 } on AssertionError catch (e) {
   error = e;
 }
 expect(error, isNull);

// Good:
// Regression test for <GitHub URL>.
// Should not trigger an assertion.
myTestCode();
// Or for async code:
await expectLater(myAsyncTestCode(), completes);

@kevmoo
Copy link
Contributor Author

kevmoo commented Jun 23, 2025

Do you want me to update things to use completes or land as-is?

@kevmoo kevmoo added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 24, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Jun 24, 2025
Merged via the queue into master with commit 8aef6e2 Jun 24, 2025
76 checks passed
@auto-submit auto-submit bot deleted the error_cleanup branch June 24, 2025 00:46
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 24, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 24, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 24, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 24, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 24, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 24, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 24, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 25, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 25, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 25, 2025
@justinmc
Copy link
Contributor

Sorry, as-is is fine 👍

auto-submit bot pushed a commit to flutter/packages that referenced this pull request Jun 26, 2025
Roll Flutter from d733bea58c1a to 2773c0c8e15e (42 revisions)

flutter/flutter@d733bea...2773c0c

2025-06-25 [email protected] Log stack traces from exceptions thrown by devicelab test tasks (flutter/flutter#171165)
2025-06-25 [email protected] Revert "Move `web_long_running_tests_{1,5}_5` to `bringup`." (flutter/flutter#171100)
2025-06-25 [email protected] Add missing M3 tests for InputDecoration.isDense (flutter/flutter#171058)
2025-06-25 [email protected] Add Android specific sub-step to validate the Android sdk path has no spaces (flutter/flutter#170829)
2025-06-24 [email protected] Update foundation library to export internal (flutter/flutter#170563)
2025-06-24 [email protected] Remove stale references to `Release-process.md` and `conductor` (flutter/flutter#171046)
2025-06-24 [email protected] License cpp jun23 (flutter/flutter#171047)
2025-06-24 [email protected] Add android-reviewers to CODEOWNERS (flutter/flutter#170157)
2025-06-24 [email protected] Update tool/README.md regarding locally-built engine (flutter/flutter#171102)
2025-06-24 [email protected] [web] Align the PR triage process with the ecosystem's triage flow (flutter/flutter#171086)
2025-06-24 [email protected] [flutter_tool] Migrate DAP off `ProcessUtils.writelnToStdinUnsafe` (flutter/flutter#171081)
2025-06-24 [email protected] [web] More granular configuration of the test environment (flutter/flutter#168767)
2025-06-24 [email protected] Clean up Devfs_Web into separate files (flutter/flutter#170769)
2025-06-24 [email protected] Add RawMenuAnchor animation callbacks (flutter/flutter#167806)
2025-06-24 [email protected] Support wide gamut colors when applying a DlColor to an SkPaint (flutter/flutter#170613)
2025-06-24 [email protected] Remove temporary workaround for web testing (flutter/flutter#170949)
2025-06-24 [email protected] Roll Packages from 02770da to d9d3191 (6 revisions) (flutter/flutter#171075)
2025-06-24 [email protected] Add LLDB warnings (flutter/flutter#170827)
2025-06-24 [email protected] Update FormField.initialValue documentation (flutter/flutter#171061)
2025-06-24 [email protected] Roll Skia from 132cb2052565 to a462e701b493 (2 revisions) (flutter/flutter#171063)
2025-06-24 [email protected] Roll Skia from f88706e3a863 to 132cb2052565 (4 revisions) (flutter/flutter#171057)
2025-06-24 [email protected] When maintainHintSize is false, hint is centered and aligned, it is different from the original one (flutter/flutter#168654)
2025-06-24 [email protected] Deprecate DropdownButtonFormField "value" parameter in favor of "initialValue" (flutter/flutter#170805)
2025-06-24 [email protected] Roll Skia from af6feb799ea6 to f88706e3a863 (2 revisions) (flutter/flutter#171056)
2025-06-24 [email protected] Roll Dart SDK from aebd78999b1a to d9edd9e7a634 (1 revision) (flutter/flutter#171053)
2025-06-24 [email protected] Roll Skia from ae517eba0170 to af6feb799ea6 (1 revision) (flutter/flutter#171052)
2025-06-24 [email protected] Roll Skia from a7735d517e6a to ae517eba0170 (9 revisions) (flutter/flutter#171049)
2025-06-24 [email protected] Enable interpretation fallback when unable to JIT on iOS. (flutter/flutter#170835)
2025-06-24 [email protected] Flutter test cleanup (flutter/flutter#170891)
2025-06-24 [email protected] Move `packages_autoroller` out of the carcass of `conductor`, delete `conductor` (flutter/flutter#171029)
2025-06-23 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Don't strip symbols from `libapp.so` on android by default (#162464)" (flutter/flutter#171044)
2025-06-23 [email protected] Roll Dart SDK from a09de0d3556c to aebd78999b1a (2 revisions) (flutter/flutter#171039)
2025-06-23 [email protected] Don't strip symbols from `libapp.so` on android by default (flutter/flutter#162464)
2025-06-23 [email protected] Roll Skia from 0311837abe86 to a7735d517e6a (12 revisions) (flutter/flutter#171037)
2025-06-23 [email protected] Pass font scanner to font mgr that need it (flutter/flutter#170701)
2025-06-23 [email protected] Make service worker tests more lenient. (flutter/flutter#170939)
2025-06-23 [email protected] Remove update CHANGELOG step from stable cherry pick process (flutter/flutter#171017)
2025-06-23 [email protected] Include dev_dependencies in all builds for iOS and macOS (flutter/flutter#171015)
2025-06-23 [email protected] Move `web_long_running_tests_{1,5}_5` to `bringup`. (flutter/flutter#171026)
2025-06-23 [email protected] rename from announce to supportsAnnounce on engine (flutter/flutter#170618)
2025-06-23 [email protected] Roll pub packages (flutter/flutter#171016)
2025-06-23 [email protected] Enhance Text Contrast for WCAG AAA Compliance (flutter/flutter#170758)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
...
mboetger pushed a commit to mboetger/flutter that referenced this pull request Jul 21, 2025
Mostly related to error tracking.
vashworth pushed a commit to vashworth/packages that referenced this pull request Jul 30, 2025
…r#9495)

Roll Flutter from d733bea58c1a to 2773c0c8e15e (42 revisions)

flutter/flutter@d733bea...2773c0c

2025-06-25 [email protected] Log stack traces from exceptions thrown by devicelab test tasks (flutter/flutter#171165)
2025-06-25 [email protected] Revert "Move `web_long_running_tests_{1,5}_5` to `bringup`." (flutter/flutter#171100)
2025-06-25 [email protected] Add missing M3 tests for InputDecoration.isDense (flutter/flutter#171058)
2025-06-25 [email protected] Add Android specific sub-step to validate the Android sdk path has no spaces (flutter/flutter#170829)
2025-06-24 [email protected] Update foundation library to export internal (flutter/flutter#170563)
2025-06-24 [email protected] Remove stale references to `Release-process.md` and `conductor` (flutter/flutter#171046)
2025-06-24 [email protected] License cpp jun23 (flutter/flutter#171047)
2025-06-24 [email protected] Add android-reviewers to CODEOWNERS (flutter/flutter#170157)
2025-06-24 [email protected] Update tool/README.md regarding locally-built engine (flutter/flutter#171102)
2025-06-24 [email protected] [web] Align the PR triage process with the ecosystem's triage flow (flutter/flutter#171086)
2025-06-24 [email protected] [flutter_tool] Migrate DAP off `ProcessUtils.writelnToStdinUnsafe` (flutter/flutter#171081)
2025-06-24 [email protected] [web] More granular configuration of the test environment (flutter/flutter#168767)
2025-06-24 [email protected] Clean up Devfs_Web into separate files (flutter/flutter#170769)
2025-06-24 [email protected] Add RawMenuAnchor animation callbacks (flutter/flutter#167806)
2025-06-24 [email protected] Support wide gamut colors when applying a DlColor to an SkPaint (flutter/flutter#170613)
2025-06-24 [email protected] Remove temporary workaround for web testing (flutter/flutter#170949)
2025-06-24 [email protected] Roll Packages from 02770da to d9d3191 (6 revisions) (flutter/flutter#171075)
2025-06-24 [email protected] Add LLDB warnings (flutter/flutter#170827)
2025-06-24 [email protected] Update FormField.initialValue documentation (flutter/flutter#171061)
2025-06-24 [email protected] Roll Skia from 132cb2052565 to a462e701b493 (2 revisions) (flutter/flutter#171063)
2025-06-24 [email protected] Roll Skia from f88706e3a863 to 132cb2052565 (4 revisions) (flutter/flutter#171057)
2025-06-24 [email protected] When maintainHintSize is false, hint is centered and aligned, it is different from the original one (flutter/flutter#168654)
2025-06-24 [email protected] Deprecate DropdownButtonFormField "value" parameter in favor of "initialValue" (flutter/flutter#170805)
2025-06-24 [email protected] Roll Skia from af6feb799ea6 to f88706e3a863 (2 revisions) (flutter/flutter#171056)
2025-06-24 [email protected] Roll Dart SDK from aebd78999b1a to d9edd9e7a634 (1 revision) (flutter/flutter#171053)
2025-06-24 [email protected] Roll Skia from ae517eba0170 to af6feb799ea6 (1 revision) (flutter/flutter#171052)
2025-06-24 [email protected] Roll Skia from a7735d517e6a to ae517eba0170 (9 revisions) (flutter/flutter#171049)
2025-06-24 [email protected] Enable interpretation fallback when unable to JIT on iOS. (flutter/flutter#170835)
2025-06-24 [email protected] Flutter test cleanup (flutter/flutter#170891)
2025-06-24 [email protected] Move `packages_autoroller` out of the carcass of `conductor`, delete `conductor` (flutter/flutter#171029)
2025-06-23 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Don't strip symbols from `libapp.so` on android by default (#162464)" (flutter/flutter#171044)
2025-06-23 [email protected] Roll Dart SDK from a09de0d3556c to aebd78999b1a (2 revisions) (flutter/flutter#171039)
2025-06-23 [email protected] Don't strip symbols from `libapp.so` on android by default (flutter/flutter#162464)
2025-06-23 [email protected] Roll Skia from 0311837abe86 to a7735d517e6a (12 revisions) (flutter/flutter#171037)
2025-06-23 [email protected] Pass font scanner to font mgr that need it (flutter/flutter#170701)
2025-06-23 [email protected] Make service worker tests more lenient. (flutter/flutter#170939)
2025-06-23 [email protected] Remove update CHANGELOG step from stable cherry pick process (flutter/flutter#171017)
2025-06-23 [email protected] Include dev_dependencies in all builds for iOS and macOS (flutter/flutter#171015)
2025-06-23 [email protected] Move `web_long_running_tests_{1,5}_5` to `bringup`. (flutter/flutter#171026)
2025-06-23 [email protected] rename from announce to supportsAnnounce on engine (flutter/flutter#170618)
2025-06-23 [email protected] Roll pub packages (flutter/flutter#171016)
2025-06-23 [email protected] Enhance Text Contrast for WCAG AAA Compliance (flutter/flutter#170758)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
...
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. f: routes Navigator, Router, and related APIs. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants