9

I'm adding integration testing (using the integration_test package) to my app but I am running into a problem.

Let me explain. The first step when my app launch is authentication for which I have 3 options: firebase email link, firebase google sign in, and firebase facebook sign in.

What is blocking me is that all these sign in methods require actions outside of the main app dart code and thus are not accessible by flutter driver.

Am I missing something here? And if not how should that case be handled?

Cheers!

Théo Champion
  • 1,701
  • 1
  • 21
  • 46

3 Answers3

2

To make the test less flaky i would recommend to not rely on an internet connection or a third party (like Firebase or Google login).

I would advise to use a Mock for this. So when you try to login to your test you send a fake response, and in that way you can continue using the app.

The following article explains how to use a mock: https://medium.com/stuart-engineering/mocking-integration-tests-with-flutter-af3b6ba846c7

1

You can use Patrol – it lets you interact with native system UI from within your Flutter integration tests. Example:

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

void main() {
  patrolTest(
  'signs in', 
  nativeAutomation: true,
  (PatrolTester $) async {
    await $.native.enterText(
      Selector(textContains: 'Email'),
      text: 'tester@awesomeapp.pl'),
    );
    await $.native.enterText(
      Selector(textContains: 'Password'),
      text: 'ny4ncat'),
    );
    await $.native.tap(Selector(text: 'Continue'));

     // you should be signed in
  });
}
Bartek Pacia
  • 1,085
  • 3
  • 15
  • 37
0

You can add the fourth way of signing in - using username and password. Firebase should support this kind of very common situation, so you can do it within lines of code.

If you do not want the end users to login by password, you can simply disable this method in production build and only enable it in debug build.

Another way is to mock your authentication system. In other words, when doing testing, you have a button called "fake sign in", and your integration test driver just click that button.

ch271828n
  • 15,854
  • 5
  • 53
  • 88