Writing tests for an Android app that logs into Fa

2019-02-26 07:16发布

问题:

My Android app uses FacebookSDK for login. It's the first screen, and you can't do anything unless you login.

I want to write some Espresso tests to be ran on Greenhouse Continuous integration server.

I searched and I found FBSDKTestUsersManager on iOS, but nothing similar on Android.

What I plan to do is create a flavor of test and when that flavor is selected instead of a normal Facebook login button, I'd display a button that gets a test access token for the user, then brings them to the homepage of the app. However, I can't do that cause FBSDKTestUsersManager doesn't exist on Android.

Any suggestions?

回答1:

The solution is to involve UIAutomator in your tests together with Espresso for Android. It will be possible to go outside of your app under test context and perform some actions on Facebook login dialog. Similar question here and the example in my blog post.