I have an app, it is very simple and have just one widget. It is working fine, however when I run integration test by calling:
$ flutter drive --target=test_driver/app.dart
I get the following error:
file:///Users/myuser/flutter/packages/flutter_test/lib/src/accessibility.dart:8:8: Error: Not found: 'dart:ui' import 'dart:ui' as ui; ^ file:///Users/myuser/flutter/packages/flutter_test/lib/src/binding.dart:8:8: Error: Not found: 'dart:ui' import 'dart:ui' as ui; ^ file:///Users/myuser/flutter/packages/flutter_test/lib/src/matchers.dart:8:8: Error: Not found: 'dart:ui' import 'dart:ui' as ui; ^ file:///Users/myuser/flutter/packages/flutter_test/lib/src/matchers.dart:9:8: Error: Not found: 'dart:ui' import 'dart:ui'; ^ file:///Users/myuser/flutter/packages/flutter_test/lib/src/test_pointer.dart:12:1: Error: Not found: 'dart:ui' export 'dart:ui' show Offset; ^ file:///Users/myuser/flutter/packages/flutter/lib/src/rendering/binding.dart:8:8: Error: Not found: 'dart:ui' import 'dart:ui' as ui show window; ^ file:///Users/myuser/flutter/packages/flutter/lib/src/rendering/box.dart:6:8: Error: Not found: 'dart:ui' import 'dart:ui' as ui show lerpDouble; ^ file:///Users/myuser/flutter/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart:6:8: Error: Not found: 'dart:ui' import 'dart:ui' as ui; ^ file:///Users/myuser/flutter/packages/flutter/lib/src/rendering/editable.dart:8:8: Error: Not found: 'dart:ui' import 'dart:ui' as ui show TextBox; ^ file:///Users/myuser/flutter/packages/flutter/lib/src/rendering/error.dart:5:8: Error: Not found: 'dart:ui' import 'dart:ui' as ui show Paragraph, ParagraphBuilder, ParagraphConstraints, ParagraphStyle, TextStyle; ^ Stopping application instance. Driver tests failed: 254
Note that when I run the app from Android Studio, it runs successfully. But when I run from terminal using the command quoted above, the app shows a white screen and it doesn't move from there until I get the error on my terminal.
Assuming it's a path issue, like test_driver not finding flutter packages like dart:ui, how can I make sure test_driver knows where dart:ui is ?
dart:ui library Null safety. Built-in types and core primitives for a Flutter application. To use, import dart:ui . This library exposes the lowest-level services that Flutter frameworks use to bootstrap applications, such as classes for driving the input, graphics text, layout, and rendering subsystems.
The integration tests can have no imports to your main App code or other flutter code that runs in the App - otherwise they will fail with your seen error.
Have a read of https://flutter.io/cookbook/testing/integration-test-introduction/ as this gives an example of integration tests with an app starting point that allows you to run setup code before your actual driver tests run if this is what you are looking to do. Otherwise don't use key values that use constants from your main code (as mentioned here http://cogitas.net/write-integration-test-flutter/).
Make sure that the import is set to this:
import 'package:test/test.dart';
instead of this:
import 'package:flutter_test/flutter_test.dart';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With