aintno12u
aintno12u

Reputation: 401

Flutter test, integration test for complex apps

In integration test ca i do the following?,

  1. Is it possible to run integration test with apps having this kind of flow: app starts -> splash screen-> ad with close button -> amplify auth login screen -> home -> menu home buttons -> another screen so and so..?

  2. Run integration test bypass login screen and do integration test to specific part of the app only

Upvotes: 1

Views: 841

Answers (1)

BenVercammen
BenVercammen

Reputation: 91

  1. It is, but you'll have to make sure that you can stub/mock all "external" components, the ones you don't really have control over (eg: external ad server, authentication service, ...). You need to be able to take control over these in order to decide for yourself which possible scenario's will play out (eg: ad doesn't load, authentication failed, ...) and also to avoid being dependent on those external components while running your tests. Your best bet is to make sure that you can inject mock versions of the required services and widgets into your application. This might take some refactoring at first, but in the end it should result in clean and better testable code.
  2. Personally, I'm using firebase_auth for authentication. In the setUp of your integration tests, you can then "pretend" the user is already authenticated through the use of MockFirebaseAuth (see firebase_auth_mocks). The idea is the same as in point 1; the firebase authentication service is being mocked, and will just provide the type of User object that you want it to, which would probably be a successfully authenticated user in most cases.

Edit: your app should be set up in such a way that it will first check whether or not the user is already authenticated. If so, just skip the login screen. This way, when the authentication service provides an already authenticated user, the login screen will be bypassed and you can continue testing the rest of your app without having to fill in credentials every single time...

Upvotes: 1

Related Questions