問題描述
我正在尋找一種方法來提供登錄"到我的應用程序,以便自動測試已登錄"并可以測試整個應用程序.目前它當然被登錄屏幕阻止了.
I'm looking for a way to "provide a login" to my app so an automated test "is logged in" and can test the entire app. Currently it's of course blocked by the login-screen.
因為我使用 SmartLock 作為密碼,這可能是提供一些測試憑據的機會 - 但我不知道如何.
Because I'm using SmartLock for Passwords, this might be a chance to provide some credentials for the test - but I don't know how.
是否有一些最佳實踐可以在測試期間提供憑據以/跳過登錄?我可以想到一個特殊的 buildType/-flavor 來模擬登錄,但這樣它就不能用于測試發(fā)布版本.
Is there some best-practice to provide credentials to / skip the login during a test? I could think of a special buildType / -flavor which is mocking the login but this way it can't be used to test a release build.
如果我可以測試最終發(fā)布版本,并且在測試成功后可以上傳到商店,那就太好了.這樣,我也可以使用 PlayStore 中嵌入的發(fā)布前報告(這真的很棒).
It would be great when I could test a final release build which can be uploaded to the store when the test succeeds. This way, I could use the embedded pre-launch-reports in the PlayStore as well (which would be really nice).
推薦答案
進入Firebase Console->Test Lab->選擇Dimensions,然后點擊
Go to Firebase Console->Test Lab->Select Dimensions, then click
顯示高級選項
然后尋找
測試帳戶憑據(可選)
然后填寫如下:
輸入用戶名資源
:您的用戶名(電子郵件)EditText 資源的名稱,跳過 R.id
部分,因此對于 R.id.edit_text_email
輸入 edit_text_email
Enter username resource
:
name of your username (email) EditText resource, skipping the R.id
part, so for R.id.edit_text_email
input edit_text_email
輸入密碼資源
:同上,但輸入密碼.同樣,跳過 R.id
,例如.edit_text_password
Enter username
:您將用于測試的用戶名或電子郵件,例如.test@mywebsite.com
輸入密碼
:您將用于測試的密碼,例如 testTEST123
似乎 Robo(測試機器人)在找到使用 ID 資源指定的 EditTexts 后立即輸入憑據,但如果您有其他身份驗證選項,則可能需要一些時間來確定單擊哪個按鈕登錄如使用 Google 登錄"和使用 Facebook 繼續(xù)".在其他服務中嘗試了幾分鐘后,似乎幸運地按下了正確的按鈕以使用您提供的憑據繼續(xù)進行身份驗證.
It seems Robo (the test bot) types in the credentials as soon as it finds the EditTexts specified with the ID resources, yet may take a little while figuring out which button to click to log in if you have other auth options such as 'Sign in with Google' and 'Continue with Facebook'. After a few minutes of attempts in other services it seems to luckily press the right button to continue through the authentication using the credentials you provide.
在撰寫本文時,無法編寫登錄行為腳本并因此建議使用哪些按鈕進行身份驗證,因此只需使用上述方法并給 Robo 足夠的測試時間(測試超時控制臺中的代碼>),以防它在沒有單擊右鍵的情況下停留一段時間.
At the time of writing this, there is no way to script a login behaviour and as such suggest which buttons to use for authentication, so just use the method above and give Robo enough test time (Test timeout
in the Console) in case it sticks around without clicking the right button for a while.
如果您為 Robo 提供 Sign in With Google
按鈕以使用其自己的 Google 憑據登錄,請記住,如果您提供 Test account 憑據
,這將不起作用.IE.為了能夠使用 Sign in with Google
,請確保您沒有提供任何其他登錄憑據,否則會失敗.
If you provide Sign in With Google
button for Robo to use its own Google credentials to sign in, remember that this will not work if you provide the Test account credentials
. Ie. to be able to use Sign in with Google
make sure your haven't provided any other login credentials, otherwise it will fail.
注意:您可以讓 Robo 使用類似的方法填寫其他 EditText 字段 - 檢查 測試實驗室文檔了解更多信息.
Note: You can make Robo fill in other EditText fields using a similar method - check the Test Lab documentation for more info.
這篇關于如何為自動化的 android 測試提供登錄憑據?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!