Following the instructions on the Codelab "How to test a Flutter app" through to Step 6 "Widget Testing"
on page
https://codelabs.developers.google.com/codelabs/flutter-app-testing#5
beginning with 'Testing Scrolling', widget tests throw exceptions (see below) and fail, regardless of platform and regardless if physical device or emulator. 'Testing if ListView shows up' does succeed.
Code is copy / pasted from the codelab.
Note: The unit tests and integration tests from the same codelab work as expected.
I/flutter (15446): (The following exception is now available via WidgetTester.takeException:)
I/flutter (15446): ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
I/flutter (15446): The following TestFailure object was thrown running a test:
I/flutter (15446): Expected: no matching nodes in the widget tree
I/flutter (15446): Actual: _TextFinder:<exactly one widget with text "Item 0" (ignoring offstage widgets):
I/flutter (15446): Text-[<'text_0'>]("Item 0", dependencies: [MediaQuery, DefaultTextStyle])>
I/flutter (15446): Which: means one was found but none were expected
I/flutter (15446):
I/flutter (15446): When the exception was thrown, this was the stack:
I/flutter (15446): #4 main.<anonymous closure>.<anonymous closure> (file:///Users/m/root/topics/coding/flutter/learning/testing/test/screens/home_test.dart:21:7)
I/flutter (15446): <asynchronous suspension>
I/flutter (15446): <asynchronous suspension>
I/flutter (15446): (elided one frame from package:stack_trace)
I/flutter (15446): ...
I/flutter (15446):
I/flutter (15446): This was caught by the test expectation on the following line:
I/flutter (15446): file:///Users/m/root/topics/coding/flutter/learning/testing/test/screens/home_test.dart line 21
I/flutter (15446): The test description was:
I/flutter (15446): Testing Scrolling
I/flutter (15446): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (15446): (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.)
I/flutter (15446): ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
I/flutter (15446): The following TestFailure object was thrown running a test:
I/flutter (15446): Expected: no matching nodes in the widget tree
I/flutter (15446): Actual: _TextFinder:<exactly one widget with text "Item 0" (ignoring offstage widgets):
I/flutter (15446): Text-[<'text_0'>]("Item 0", dependencies: [MediaQuery, DefaultTextStyle])>
I/flutter (15446): Which: means one was found but none were expected
I/flutter (15446):
I/flutter (15446): When the exception was thrown, this was the stack:
I/flutter (15446): #4 main.<anonymous closure>.<anonymous closure> (file:///Users/m/root/topics/coding/flutter/learning/testing/test/screens/home_test.dart:21:7)
I/flutter (15446): <asynchronous suspension>
I/flutter (15446): <asynchronous suspension>
I/flutter (15446): (elided one frame from package:stack_trace)
I/flutter (15446): ...
I/flutter (15446):
I/flutter (15446): This was caught by the test expectation on the following line:
I/flutter (15446): file:///Users/m/root/topics/coding/flutter/learning/testing/test/screens/home_test.dart line 21
I/flutter (15446): The test description was:
I/flutter (15446): Testing Scrolling
I/flutter (15446): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (15446): 00:02 +0: Home Page Widget Tests Testing Scrolling [E]
I/flutter (15446): Test failed. See exception logs above.
I/flutter (15446): The test description was: Testing Scrolling
I/flutter (15446):
I/flutter (15446): 00:02 +0 -1: Some tests failed.
flutter doctor -v
[✓] Flutter (Channel dev, 1.26.0-8.0.pre, on macOS 11.1 20C69 darwin-x64, locale
en-GB)
• Flutter version 1.26.0-8.0.pre at /Users/m/root/topics/coding/flutter/sdk
• Framework revision b9d06fffb2 (9 days ago), 2021-01-07 18:36:48 -0800
• Engine revision 42a8d4c681
• Dart version 2.12.0 (build 2.12.0-179.0.dev)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/m/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 12.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.3, Build version 12C33
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] 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)
[✓] IntelliJ IDEA Community Edition (version 2020.3.1)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin version 52.2.5
• Dart plugin version 203.6912
[✓] VS Code (version 1.52.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.18.1
[✓] Connected device (4 available)
• G8341 (mobile) • BH905PQH8Y •
android-arm64 • Android 9 (API 28)
• sdk gphone x86 arm (mobile) • emulator-5554 •
android-x86 • Android 11 (API 30) (emulator)
• midev1 (mobile) • a1dc22872978776b04ca280e3a3240adaa3fda50 •
ios • iOS 14.3
• Chrome (web) • chrome •
web-javascript • Google Chrome 87.0.4280.141
• No issues found!
Following the instructions on the Codelab "How to test a Flutter app" through to Step 6 "Widget Testing"
on page
https://codelabs.developers.google.com/codelabs/flutter-app-testing#5
beginning with 'Testing Scrolling', widget tests throw exceptions (see below) and fail, regardless of platform and regardless if physical device or emulator. 'Testing if ListView shows up' does succeed.
Code is copy / pasted from the codelab.
Note: The unit tests and integration tests from the same codelab work as expected.