fun backgroundWorkDone() {
// Background work finished.
callback.onTransitionToIdle() // Good. Tells Espresso that the app is idle.
// Don't do any post-processing work beyond this point. Espresso now
// considers your app to be idle and moves on to the next test action.
public void isIdle() {
// DON'T call callback.onTransitionToIdle() here!
public void backgroundWorkDone() {
// Background work finished.
callback.onTransitionToIdle() // Good. Tells Espresso that the app is idle.
// Don't do any post-processing work beyond this point. Espresso now
// considers your app to be idle and moves on to the next test action.
變種版本,並且只在應用程式的偵錯版本中使用閒置資源。
使用依附元件插入架構 (例如
Dagger
) 插入應用程式的閒置功能
加入測試中的資源依附元件圖如果您使用的是 Dagger 2,
插入內容應來自子元件。
在應用程式的測試中實作閒置資源,並公開
因此需要同步處理
注意:
雖然這項設計決策似乎
建立用於閒置資源的獨立參照,
除了最單純的應用程式之外,
如要進一步瞭解如何在 Android 測試中使用 Espresso,請參閱
IdlingResourceSample
:
與背景工作同步處理。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2024-08-29 (世界標準時間)。"],[],[]]