flutter-pi icon indicating copy to clipboard operation
flutter-pi copied to clipboard

Is it possible (or even conceivable) to support `flutter drive`?

Open filiph opened this issue 9 months ago • 1 comments

I would very much like to be able to run tests on a Raspberry Pi using flutter drive.

Is that somehow possible with flutter-pi? Or maybe I can build a Flutter driver bundle with flutterpi_tool?

filiph avatar Mar 13 '25 15:03 filiph

Yes, it's definitely possible. Currently it's just not implemented. What you might do as a temporary solution is something like this:

integration_test/integration_test.dart:

import 'package:integration_test/integration_test.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  IntegrationTestWidgetsFlutterBinding.ensureInitialized();

  testWidgets('test 1', (_) async {
    expect(true, true);
  });

  testWidgets('test 2', (_) async {
    expect(true, true);
  });
}

and then just launch as a normal app, via flutterpi_tool run -d pi5 -t integration_test/integration_test.dart.

However that's really only a small part of what flutter test -d does, it won't terminate the app when tests are done (you might do that via dart:io exit()), and you don't get a usable exit code from the run command, so it's not really usable in CI, if that's what you're after

ardera avatar Mar 19 '25 14:03 ardera