Using patrol test package for google sign in during integration test error

716 Views Asked by At

unable to click on the email using Patrol test

I am unable to select the particular email for google sign-in for testing

this is the error that im facing.

_AssertionError ('package:patrol/src/custom_finders/patrol_tester.dart': Failed assertion: line 131 pos 7: 'nativeAutomator != null': NativeAutomator is not initialized. Make sure you passed nativeAutomation: true to patrolTest(), and that you're not initializing any bindings in your test.)

this is the code snippet

void main() {
  patrolTest(
    'signs up',
    (PatrolTester $) async {
      IntegrationTestWidgetsFlutterBinding.ensureInitialized();
      await Firebase.initializeApp();
      configureDependencies(testing: true);
      // runZoneGuarded(() => runApp(MyApp));
      await $.pumpWidget(const MyApp());

      final getStartedButton = find.byKey(const Key("getStartedButton"));
      await $.tap(getStartedButton);
      await $.pumpAndSettle();
      await $('LOGIN WITH GOOGLE').tap();
      await $.native.tap(Selector(text: 'Neel Kothari'));
      await $.pumpAndSettle();
    },
    
  );
}
1

There are 1 best solutions below

0
On

If you want to use Patrol's native automation feature, you have to set the nativeAutomation argument to true in call to patrolTest():

void main() {
  patrolTest(
    'signs up',
    nativeAutomation: true,
    (PatrolTester $) async {
      // test code 
    },
  );
}

BTW, don't call IntegrationTestWidgetsFlutterBinding.ensureInitialized() – Patrol has its own binding which is already initialized at this point, and calling this line will conflict with Patrol's binding.