Why can't my flutter tests run on Codemagic? - flutter

I have written three simple integration tests that are located in a test directory. I run work on Windows and I use an Android emulator. They always fail on Codemagic (macOS Standard VM, 2.3GHz Quad Core / 8GB). I don't know why but it uses this flag to run the tests:
flutter test --machine
And even with the
--machine flag the tests run perfectly on my machine.
Now here are the logs when running on my machine:
{"protocolVersion":"0.1.1","runnerVersion":null,"pid":17888,"type":"start","time":0}
{"suite":{"id":0,"platform":"vm","path":"D:\\delivery\\organia-app\\test\\app_test.dart"},"type":"suite","time":0}
{"test":{"id":1,"name":"loading D:\\delivery\\organia-app\\test\\app_test.dart","suiteID":0,"groupIDs":[],"metadata":{"skip":false,"skipReason":null},"line":null,"column":null,"url":null},"type":"testStart","time":1}
{"count":1,"time":11,"type":"allSuites"}
[{"event":"test.startedProcess","params":{"observatoryUri":null}}]
{"testID":1,"result":"success","skipped":false,"hidden":true,"type":"testDone","time":2818}
{"group":{"id":2,"suiteID":0,"parentID":null,"name":"","metadata":{"skip":false,"skipReason":null},"testCount":3,"line":null,"column":null,"url":null},"type":"group","time":2824}
{"group":{"id":3,"suiteID":0,"parentID":2,"name":"Tests","metadata":{"skip":false,"skipReason":null},"testCount":3,"line":11,"column":3,"url":"file:///D:/delivery/organia-app/test/app_test.dart"},"type":"group","time":2825}
{"test":{"id":4,"name":"Tests Bottom Tab bar navigation","suiteID":0,"groupIDs":[2,3],"metadata":{"skip":false,"skipReason":null},"line":153,"column":5,"url":"package:flutter_test/src/widget_tester.dart","root_line":12,"root_column":5,"root_url":"file:///D:/delivery/organia-app/test/app_test.dart"},"type":"testStart","time":2826}
{"testID":4,"messageType":"print","message":"Error loading AssetManifest.json, e: Unable to load asset: AssetManifest.json","type":"print","time":3843}
{"testID":4,"result":"success","skipped":false,"hidden":false,"type":"testDone","time":4769}
{"test":{"id":5,"name":"Tests Register Test","suiteID":0,"groupIDs":[2,3],"metadata":{"skip":false,"skipReason":null},"line":153,"column":5,"url":"package:flutter_test/src/widget_tester.dart","root_line":25,"root_column":5,"root_url":"file:///D:/delivery/organia-app/test/app_test.dart"},"type":"testStart","time":4770}
{"testID":5,"result":"success","skipped":false,"hidden":false,"type":"testDone","time":7083}
{"test":{"id":6,"name":"Tests Login Test","suiteID":0,"groupIDs":[2,3],"metadata":{"skip":false,"skipReason":null},"line":153,"column":5,"url":"package:flutter_test/src/widget_tester.dart","root_line":53,"root_column":5,"root_url":"file:///D:/delivery/organia-app/test/app_test.dart"},"type":"testStart","time":7084}
{"testID":6,"result":"success","skipped":false,"hidden":false,"type":"testDone","time":9332}
{"test":{"id":7,"name":"(tearDownAll)","suiteID":0,"groupIDs":[2],"metadata":{"skip":false,"skipReason":null},"line":42,"column":5,"url":"package:integration_test/integration_test.dart","root_line":8,"root_column":40,"root_url":"file:///D:/delivery/organia-app/test/app_test.dart"},"type":"testStart","time":9332}
{"testID":7,"messageType":"print","message":"Warning: integration_test plugin was not detected.","type":"print","time":9338}
{"testID":7,"messageType":"print","message":"","type":"print","time":9339}
{"testID":7,"messageType":"print","message":"If you're running the tests with `flutter drive`, please make sure your tests","type":"print","time":9339}
{"testID":7,"messageType":"print","message":"are in the `integration_test/` directory of your package and use","type":"print","time":9339}
{"testID":7,"messageType":"print","message":"`flutter test $path_to_test` to run it instead.","type":"print","time":9340}
{"testID":7,"messageType":"print","message":"","type":"print","time":9340}
{"testID":7,"messageType":"print","message":"If you're running the tests with Android instrumentation or XCTest, this means","type":"print","time":9340}
{"testID":7,"messageType":"print","message":"that you are not capturing test results properly! See the following link for","type":"print","time":9340}
{"testID":7,"messageType":"print","message":"how to set up the integration_test plugin:","type":"print","time":9341}
{"testID":7,"messageType":"print","message":"","type":"print","time":9341}
{"testID":7,"messageType":"print","message":"https://flutter.dev/docs/testing/integration-tests#testing-on-firebase-test-lab","type":"print","time":9341}
{"testID":7,"messageType":"print","message":"","type":"print","time":9342}
{"testID":7,"result":"success","skipped":false,"hidden":true,"type":"testDone","time":9342}
{"success":true,"type":"done","time":9384}
And here is the Codemagic log:
== QA ==
> flutter analyze
Running "flutter pub get" in clone... 1,971ms
Analyzing clone...
No issues found! (ran in 25.4s)
> flutter test --machine
{"protocolVersion":"0.1.1","runnerVersion":null,"pid":2616,"type":"start","time":0}
{"suite":{"id":0,"platform":"vm","path":"/Users/builder/clone/test/app_test.dart"},"type":"suite","time":1}
{"test":{"id":1,"name":"loading /Users/builder/clone/test/app_test.dart","suiteID":0,"groupIDs":[],"metadata":{"skip":false,"skipReason":null},"line":null,"column":null,"url":null},"type":"testStart","time":3}
{"count":1,"time":16,"type":"allSuites"}
[{"event":"test.startedProcess","params":{"observatoryUri":null}}]
{"testID":1,"result":"success","skipped":false,"hidden":true,"type":"testDone","time":25585}
{"group":{"id":2,"suiteID":0,"parentID":null,"name":"","metadata":{"skip":false,"skipReason":null},"testCount":3,"line":null,"column":null,"url":null},"type":"group","time":25595}
{"group":{"id":3,"suiteID":0,"parentID":2,"name":"Navigation Tests","metadata":{"skip":false,"skipReason":null},"testCount":3,"line":11,"column":3,"url":"file:///Users/builder/clone/test/app_test.dart"},"type":"group","time":25596}
{"test":{"id":4,"name":"Navigation Tests Bottom Tab bar navigation","suiteID":0,"groupIDs":[2,3],"metadata":{"skip":false,"skipReason":null},"line":153,"column":5,"url":"package:flutter_test/src/widget_tester.dart","root_line":12,"root_column":5,"root_url":"file:///Users/builder/clone/test/app_test.dart"},"type":"testStart","time":25596}
{"testID":4,"messageType":"print","message":"══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════","type":"print","time":26162}
{"testID":4,"messageType":"print","message":"The following MissingPluginException was thrown running a test:","type":"print","time":26163}
{"testID":4,"messageType":"print","message":"MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on","type":"print","time":26163}
{"testID":4,"messageType":"print","message":"channel plugins.flutter.io/path_provider_macos)","type":"print","time":26163}
{"testID":4,"messageType":"print","message":"","type":"print","time":26163}
{"testID":4,"messageType":"print","message":"When the exception was thrown, this was the stack:","type":"print","time":26163}
{"testID":4,"messageType":"print","message":"#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:175:7)","type":"print","time":26163}
{"testID":4,"messageType":"print","message":"<asynchronous suspension>","type":"print","time":26163}
{"testID":4,"messageType":"print","message":"<asynchronous suspension>","type":"print","time":26164}
{"testID":4,"messageType":"print","message":"(elided one frame from package:stack_trace)","type":"print","time":26164}
{"testID":4,"messageType":"print","message":"","type":"print","time":26165}
{"testID":4,"messageType":"print","message":"The test description was:","type":"print","time":26165}
{"testID":4,"messageType":"print","message":" Bottom Tab bar navigation","type":"print","time":26165}
{"testID":4,"messageType":"print","message":"════════════════════════════════════════════════════════════════════════════════════════════════════","type":"print","time":26165}
{"testID":4,"error":"Test failed. See exception logs above.\nThe test description was: Bottom Tab bar navigation","stackTrace":"","isFailure":false,"type":"error","time":26175}
{"testID":4,"error":"'package:flutter_test/src/binding.dart': Failed assertion: line 1649 pos 12: '_pendingFrame == null': is not true.","stackTrace":"dart:core _AssertionError._throwNew\npackage:flutter_test/src/binding.dart 1649:12 LiveTestWidgetsFlutterBinding.postTest\n","isFailure":false,"type":"error","time":26207}
{"testID":4,"result":"error","skipped":false,"hidden":false,"type":"testDone","time":26207}
{"test":{"id":5,"name":"Navigation Tests Register Test","suiteID":0,"groupIDs":[2,3],"metadata":{"skip":false,"skipReason":null},"line":153,"column":5,"url":"package:flutter_test/src/widget_tester.dart","root_line":25,"root_column":5,"root_url":"file:///Users/builder/clone/test/app_test.dart"},"type":"testStart","time":26208}
{"testID":5,"error":"'package:flutter_test/src/binding.dart': Failed assertion: line 1624 pos 12: '!inTest': is not true.","stackTrace":"dart:core _AssertionError._throwNew\npackage:flutter_test/src/binding.dart 1624:12 LiveTestWidgetsFlutterBinding.runTest\npackage:integration_test/integration_test.dart 223:17 IntegrationTestWidgetsFlutterBinding.runTest\npackage:flutter_test/src/widget_tester.dart 163:24 testWidgets.<fn>\n","isFailure":false,"type":"error","time":26216}
{"testID":5,"error":"'package:flutter_test/src/binding.dart': Failed assertion: line 1648 pos 12: '!_expectingFrame': is not true.","stackTrace":"dart:core _AssertionError._throwNew\npackage:flutter_test/src/binding.dart 1648:12 LiveTestWidgetsFlutterBinding.postTest\n","isFailure":false,"type":"error","time":26220}
{"testID":5,"result":"error","skipped":false,"hidden":false,"type":"testDone","time":26220}
{"test":{"id":6,"name":"Navigation Tests Login Test","suiteID":0,"groupIDs":[2,3],"metadata":{"skip":false,"skipReason":null},"line":153,"column":5,"url":"package:flutter_test/src/widget_tester.dart","root_line":53,"root_column":5,"root_url":"file:///Users/builder/clone/test/app_test.dart"},"type":"testStart","time":26221}
{"testID":4,"messageType":"print","message":"══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════","type":"print","time":26247}
{"testID":4,"messageType":"print","message":"The following TestFailure was thrown running a test (but after the test had completed):","type":"print","time":26247}
{"testID":4,"messageType":"print","message":"Expected: exactly one matching node in the widget tree","type":"print","time":26247}
{"testID":4,"messageType":"print","message":" Actual: _WidgetIconFinder:<zero widgets with icon \"IconData(U+0F8BD)\" (ignoring offstage widgets)>","type":"print","time":26248}
{"testID":4,"messageType":"print","message":" Which: means none were found but one was expected","type":"print","time":26248}
{"testID":4,"messageType":"print","message":"","type":"print","time":26248}
{"testID":4,"messageType":"print","message":"When the exception was thrown, this was the stack:","type":"print","time":26248}
{"testID":4,"messageType":"print","message":"#0 fail (package:test_api/src/expect/expect.dart:137:31)","type":"print","time":26249}
{"testID":4,"messageType":"print","message":"#1 _expect (package:test_api/src/expect/expect.dart:132:3)","type":"print","time":26249}
{"testID":4,"messageType":"print","message":"#2 expect (package:test_api/src/expect/expect.dart:46:3)","type":"print","time":26249}
{"testID":4,"messageType":"print","message":"#3 expect (package:flutter_test/src/widget_tester.dart:455:16)","type":"print","time":26250}
{"testID":4,"messageType":"print","message":"#4 main.<anonymous closure>.<anonymous closure> (file:///Users/builder/clone/test/app_test.dart:15:7)","type":"print","time":26250}
{"testID":4,"messageType":"print","message":"<asynchronous suspension>","type":"print","time":26250}
{"testID":4,"messageType":"print","message":"<asynchronous suspension>","type":"print","time":26251}
{"testID":4,"messageType":"print","message":"(elided one frame from package:stack_trace)","type":"print","time":26251}
{"testID":4,"messageType":"print","message":"════════════════════════════════════════════════════════════════════════════════════════════════════","type":"print","time":26251}
{"testID":6,"error":"'package:flutter_test/src/binding.dart': Failed assertion: line 1624 pos 12: '!inTest': is not true.","stackTrace":"dart:core _AssertionError._throwNew\npackage:flutter_test/src/binding.dart 1624:12 LiveTestWidgetsFlutterBinding.runTest\npackage:integration_test/integration_test.dart 223:17 IntegrationTestWidgetsFlutterBinding.runTest\npackage:flutter_test/src/widget_tester.dart 163:24 testWidgets.<fn>\n","isFailure":false,"type":"error","time":26264}
{"testID":6,"result":"error","skipped":false,"hidden":false,"type":"testDone","time":26265}
{"test":{"id":7,"name":"(tearDownAll)","suiteID":0,"groupIDs":[2],"metadata":{"skip":false,"skipReason":null},"line":42,"column":5,"url":"package:integration_test/integration_test.dart","root_line":8,"root_column":40,"root_url":"file:///Users/builder/clone/test/app_test.dart"},"type":"testStart","time":26266}
{"testID":7,"messageType":"print","message":"Warning: integration_test plugin was not detected.","type":"print","time":26321}
{"testID":7,"messageType":"print","message":"","type":"print","time":26321}
{"testID":7,"messageType":"print","message":"If you're running the tests with `flutter drive`, please make sure your tests","type":"print","time":26322}
{"testID":7,"messageType":"print","message":"are in the `integration_test/` directory of your package and use","type":"print","time":26322}
{"testID":7,"messageType":"print","message":"`flutter test $path_to_test` to run it instead.","type":"print","time":26323}
{"testID":7,"messageType":"print","message":"","type":"print","time":26323}
{"testID":7,"messageType":"print","message":"If you're running the tests with Android instrumentation or XCTest, this means","type":"print","time":26323}
{"testID":7,"messageType":"print","message":"that you are not capturing test results properly! See the following link for","type":"print","time":26323}
{"testID":7,"messageType":"print","message":"how to set up the integration_test plugin:","type":"print","time":26324}
{"testID":7,"messageType":"print","message":"","type":"print","time":26324}
{"testID":7,"messageType":"print","message":"https://flutter.dev/docs/testing/integration-tests#testing-on-firebase-test-lab","type":"print","time":26324}
{"testID":7,"messageType":"print","message":"","type":"print","time":26324}
{"testID":7,"result":"success","skipped":false,"hidden":true,"type":"testDone","time":26326}
{"success":false,"type":"done","time":26368}
QA failed :|
Flutter test run failed.
== QA failed, ending build ==
Build failed :|
Test run failed: Flutter test run failed.

from the log your error is this one (you can find it in Codemagic UI too)
MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider_macos)
Seems you need to fix your unit tests that using path_provider package since they can't be run on macOS. Maybe this link https://pub.dev/packages/path_provider#testing will be helpful

Related

I'm working on macbook air m2 and this message appears when i try to run the testing flutter app

I'm working on macbook air m2 and this message appears when i try to run the emulator testing flutter app. i just want to make sure that it works before i begin working on my project.
FAILURE: Build failed with an exception.
* Where:
Script '/Users/ahmed/Developer/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1159
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/Users/ahmed/Developer/flutter/bin/flutter'' finished with non-zero exit value 1
After running this command: $ sudo softwareupdate --install-rosetta --agree-to-license, the problem appears to have been fixed.

Error: 'kethrow' isn't a type. kethrow _ClientSocketException(error, request.url);

Building flutter application is giving an error.When i try to build my application the error is occured.
The error is:
**/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/io_client.dart:88:7: Error: 'kethrow' isn't a type.
kethrow _ClientSocketException(error, request.url);
^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/io_client.dart:88:15: Error: Expected ';' after this.
kethrow _ClientSocketException(error, request.url);
^^^^^^^^^^^^^^^^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/io_client.dart:88:43: Error: Expected ')' before this.
kethrow _ClientSocketException(error, request.url);
^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/io_client.dart:48:30: Error: A non-null value must be returned since the return type 'IOStreamedResponse' doesn't allow null.
- 'IOStreamedResponse' is from 'package:http/src/io_streamed_response.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/io_streamed_response.dart').
package:http/src/io_streamed_response.dart:1
Future<IOStreamedResponse> send(BaseRequest request) async {
^
3
FAILURE: Build failed with an exception.
* Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1156
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 5m 45s
Exception: Gradle task assembleDebug failed with exit code 1**
How to fix this error.Thanks in advance.
I ran into this error a few days ago. It is strangely from the dart file. Mine was 'heethrow'. I corrected it by following the link to the file: /C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/io_client.dart.
How to go about it:
Open location /C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/ in Visual Studio Code
inside the src folder, open io_client.dart
(make sure you're in the io_client.dart inside the src folder)
Once you're in io_client.dart, locate the place with the error: in your case, it says 88:7 that is, line 88 column 7. Scroll to line number 88 and change 'kethrow' to 'throw'
the errors in the other places as marked in the image below should be corrected and your io_client.dart should be error free.
Note: other files outside io_client.dart might mark red indicating errors but never mind. Just save your changes in the io_client.dart file and close the file. Once closed
Open your project again and run flutter clean in the terminal.
next run flutter pub get
next run flutter pub upgrade
run your app again, everything should work fine.
But I'd advise you don't always go into those files to edit anything. I did that because I've tried every possible solution and needed to deliver my work. I even installed Visual Studio for Windows as suggested by flutter doctor, but that was not the solution.

Flutter - build failed in

run code after one year then face this issue
when flutter run command then command response error
how can remove these error
also run command flutter create -t app
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_math_fork-0.3.3+1/lib/src/widgets/selectable.dart:407:7: Error: The non-abstract class 'InternalSelectableMathState' is missing implementations for these members:
TextSelectionDelegate.copySelection
TextSelectionDelegate.cutSelection
TextSelectionDelegate.pasteText
TextSelectionDelegate.selectAll
Try to either
provide an implementation,
inherit an implementation from a superclass or mixin,
mark the class as abstract, or
provide a 'noSuchMethod' implementation.
class InternalSelectableMathState extends State
^^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/services/text_input.dart:1034:8: Context: 'TextSelectionDelegate.copySelection' is defined here.
void copySelection(SelectionChangedCause cause);
^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/services/text_input.dart:1014:8: Context: 'TextSelectionDelegate.cutSelection' is defined here.
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1102
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 25s
Running Gradle task 'assembleDebug'... 26.1s
Exception: Gradle task assembleDebug failed with exit code 1
Well, I hate bringing you bad news, but Flutter received a LOT of updates. You might want to either
Use an older version of Flutter (see: THIS LINK)
Refactor your code to adhere to the changes

Error when Input is : C:\src\flutter>flutter doctor

On setting up Flutter:
error :CreateProcessW failed 193
CreateProcessW failed 193
Unhandled exception:
ProcessException: %1 is not a valid Win32 application.
i have Tried changing username
from the Command prompt run the flutter doctor inside the flutter installation directory:
C:\src\flutter> flutter doctor

Library 'uuid' from dart doesn't work with flutter?

I tried flutter run after adding the dependencies of the Dart Library Uuid.
My changed dependencies
dependencies:
uuid: 0.5.0 // or also - uuid: "^0.5.3"
Errors from Flutter
Error: 'package:convert/src/hex/encoder.dart': malformed type: line 20 pos 13: cannot resolve class 'ChunkedConverter' from 'HexEncoder'
extends ChunkedConverter<List<int>, String, List<int>, String> {
^
Failed to run the Flutter compiler. Exit code: 254
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\xxxx\Flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 329
* What went wrong:
Execution failed for task ':app:flutterBuildDebug'.
> Process 'command 'C:\Users\xxxx\Flutter\flutter\bin\flutter.bat'' finished with non-zero exit value 254
Why does this not work with flutter?
After reading https://github.com/dart-lang/sdk/issues/29543#issuecomment-298888237 I think you might want to try adding a pubspec dependency on convert: "^2.0.1". Does that help?