問題描述
我的 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 持續(xù)集成服務器上運行.
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 一起參與您的測試.可以在測試環(huán)境下離開您的應用程序并在 Facebook 登錄對話框上執(zhí)行一些操作.類似的問題這里和我的博文.
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 應用編寫測試的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!