Writing tests for an Android app that logs into Facebook(为登录 Facebook 的 Android 应用编写测试)
问题描述
我的 Android 应用使用 FacebookSDK
进行登录.这是第一个屏幕,除非您登录,否则您无法进行任何操作.
My Android app uses FacebookSDK
for login. It's the first screen, and you can't do anything unless you login.
我想编写一些 Espresso
测试以在 Greenhouse 持续集成服务器上运行.
I want to write some Espresso
tests to be ran on Greenhouse Continuous integration server.
我在 iOS 上搜索并找到了 FBSDKTestUsersManager,但在 Android 上没有类似的东西.
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的应用程序.但是,我不能这样做,因为 Android 上不存在 FBSDKTestUsersManager.
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.
有什么建议吗?
推荐答案
解决方案是将 UIAutomator 与 Espresso for Android 一起参与您的测试.可以在测试环境下离开您的应用程序并在 Facebook 登录对话框上执行一些操作.类似的问题这里和我的博文.
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.
这篇关于为登录 Facebook 的 Android 应用编写测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!