Skip to content

[codelab][flutter_app_testing] Widget test fails when run on device #82542

@NZhlebinkov

Description

@NZhlebinkov

Steps to Reproduce

Expected results: The Simulator clicks on the button, the button is activated and the test passes.

Actual results: When run in VSCode the test passes. I went with the debugger line by line and it's working well.
When run in the Simulator it fails. tester.tap() doesn't activate the button even though a target is placed above it.

NOTE: Widget tests from the Google codelabs - https://codelabs.developers.google.com/codelabs/flutter-app-testing#5 and that didn't happen on Tuesday (11-05-2021). Both tester.fling() and tester.tap() seem to not work today on the Simulator and they worked fine on Tuesday

Logs
Running with unsound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety
flutter: 00:12 +2: Home Page Widget Tests Testing IconButtons
flutter: (The following exception is now available via WidgetTester.takeException:)
flutter: ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
flutter: The following TestFailure object was thrown running a test:
flutter:   Expected: exactly one matching node in the widget tree
flutter:   Actual: _TextFinder:<zero widgets with text "Added to favorites." (ignoring offstage widgets)>
flutter:    Which: means none were found but one was expected
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #4      main.<anonymous closure>.<anonymous closure> (file:///Users/lionbrunch/Work/testing_app/test/home_test.dart:77:7)
flutter: <asynchronous suspension>
flutter: <asynchronous suspension>
flutter: (elided one frame from package:stack_trace)
flutter: ...
flutter:
flutter: This was caught by the test expectation on the following line:
flutter:   file:///Users/lionbrunch/Work/testing_app/test/home_test.dart line 77
flutter: The test description was:
flutter:   Testing IconButtons
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: (If WidgetTester.takeException is called, the above exception will be ignored. If it is not, then the above exception will be dumped when another exception is caught by the framework or when the test ends, whichever happens first, and then the test will fail due to having not caught or expected the exception.)
flutter: ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
flutter: The following TestFailure object was thrown running a test:
flutter:   Expected: exactly one matching node in the widget tree
flutter:   Actual: _TextFinder:<zero widgets with text "Added to favorites." (ignoring offstage widgets)>
flutter:    Which: means none were found but one was expected
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #4      main.<anonymous closure>.<anonymous closure> (file:///Users/lionbrunch/Work/testing_app/test/home_test.dart:77:7)
flutter: <asynchronous suspension>
flutter: <asynchronous suspension>
flutter: (elided one frame from package:stack_trace)
flutter: ...
flutter:
flutter: This was caught by the test expectation on the following line:
flutter:   file:///Users/lionbrunch/Work/testing_app/test/home_test.dart line 77
flutter: The test description was:
flutter:   Testing IconButtons
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: 00:25 +2: Home Page Widget Tests Testing IconButtons [E]
flutter:   Test failed. See exception logs above.
  The test description was: Testing IconButtons
flutter:
flutter: 00:25 +2 -1: Some tests failed.
Analyzing flutter...                                                    

   info • Don't import implementation files from another package • lib/generated_plugin_registrant.dart:9:8 • implementation_imports
   info • Cancel instances of dart.async.StreamSubscription • lib/src/models/ui/PaginatedList.dart:46:23 • cancel_subscriptions

2 issues found. (ran in 3.7s)
[✓] Flutter (Channel stable, 2.0.4, on macOS 11.2.1 20D74 darwin-arm, locale en-GB)
    • Flutter version 2.0.4 at /Users/lionbrunch/Development/Flutter/flutter_SDK
    • Framework revision b1395592de (6 weeks ago), 2021-04-01 14:25:01 -0700
    • Engine revision 2dce47073a
    • Dart version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/lionbrunch/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.56.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.22.0

[✓] Connected device (1 available)
    • iPhone X (mobile) • 24567A0D-7633-4579-B558-FD712FF8A2F1 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority issues at the top of the work lista: tests"flutter test", flutter_test, or one of our testsc: crashStack traces logged to the consolec: regressionIt was better in the past than it is nowf: scrollingViewports, list views, slivers, etc.found in release: 2.0Found to occur in 2.0found in release: 2.3Found to occur in 2.3frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions