1

I'm writing some flutter integration tests that I want to run utilising flutter drive to see them in action. The tests work as expected when running good old flutter test.

I'm trying to run the very same tests using flutter drive, where they worked when I had all the code in the single file, but now I've refactored into multiple files, it doesn't work.

I've separated out some of my tester actions in to a separate dart file, so I can complete tests with a robot style approach. But now that I import my robot in to the test, I get the following error when running flutter drive:

org-dartlang-app:/my_end_to_end_test.dart:7:8: Error: Error when reading 'org-dartlang-app:/robots/add_items_to_list_robot.dart': File not found import '../robots/add_items_to_list_robot.dart';

Here is an example of the test and robot too:

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

import '../robots/add_items_to_list_robot.dart';

void main(){
  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  setupLocator();

  group('List should', () { 
     testWidgets('Add an item when the add button is selected', () async {
        // Given
        await tester.pumpWidget(const myApp());

        // When
        await tester.typeTextInTextArea('My list item');
        await tester.clickAddToListButton();

        // Then
        expect(this, that); // You know what I'm getting at
     });
  });
}
extension ListItemRobot on WidgetTest {
   Future<void> typeTextInTextArea(String text) {
       // This gets the text area, enters the text
       await pumpAndSettle();
   }

   Future<void> clickAddToListButton() {
       final button = find.byKey(Key('AddButton'));

       await tap(button);
       await pumpAndSettle();
   }
}
Lloyd Powell
  • 18,270
  • 17
  • 87
  • 123

0 Answers0