Search code examples
flutterintegration-testingflutter-test

How to write Integration test: Forced logout by logging in from another terminal? #Flutter


I am using webview for logging in my application. If i log in that account on device A, device B automatically logs out. Thanks for the help


Solution

  • There are a couple different paths you could take on this one:

    1. Fake the check if another device logs out.

    For this one, whatever call you make to see if the user should automatically log out, inject a mock or a fake to force it to say "yes, log out".

    I'd suggest combining this with a separate test on the backend that ensures that when someone logs in, the old credentials are flagged as expired as well. Between the two, you have good coverage that the system as a whole works.

    2. Manually test this functionality with two devices.

    This is pretty self explanatory, but trying to get two separate automated tests to run in the proper order on two different devices consistently is probably not worth the effort. Especially when a quick manual test can verify this functionality when a full end to end validation is required.


    It wouldn't be a bad idea to do both options above. #1 for quick validations during development, then do #2 as part of your major release process.