最近,Google Play 正在“审查”发布到 Google Play 的新应用程序。
我的应用程序要求审阅者拥有演示帐户,否则用户无法通过初始屏幕。
我向审稿人提供模拟账户的地方在哪里?
所以我使用的是 android 导航组件,但我遇到了问题(2.2.0-rc04 版本)。
我有一个welcomeFragment(wF)。从wF我想导航到loginSellerFragment不同导航图中的 (lSF)。我也不想wF在导航到时从 backstack (popUpTo, popUpToInclusive) 中删除,lSF因为用户可能想回到它。
<fragment
android:id="@+id/welcomeFragment">
<action
android:id="@+id/action_welcomeFragment_to_nav_onboarding_seller"
app:launchSingleTop="true"
app:destination="@id/nav_onboarding_seller" />
</fragment>
Run Code Online (Sandbox Code Playgroud)
导航到 lSF 后,backstack 如下所示:wF lSF
我们lSF现在开始,登录后我们想转到feedFragment(fF) ,它再次位于单独的图表中,但这次我们想清除所有后台堆栈,因为如果用户登录并按回,他希望应用程序退出,不是为了带他回到wFor lSF,所以我popUpTo="@id/loginSellerFragment popUpToInclusive='true"在动作中使用了lSFto fF。
<fragment
android:id="@+id/loginSellerFragment">
<action
android:id="@+id/action_login_to_seller"
app:destination="@+id/seller" . //this is the graph that has as firstDestination, feedFragment
app:launchSingleTop="true"
app:popUpTo="@id/loginSellerFragment"
app:popUpToInclusive="true" />
</fragment>
Run Code Online (Sandbox Code Playgroud)
所以在这个时刻的 backstack 应该只有fF因为我们删除了所有的东西lSF(lSF包括) …
我想用 来模拟和测试我Presenter的Observable,但我不知道该怎么做,代码的主要部分如下:
//in my presenter:
override fun loadData(){
this.disposable?.dispose()
this.disposable =
Observable.create<List<Note>> {emitter->
this.notesRepository.getNotes {notes->
emitter.onNext(notes)
}
}
.doOnSubscribe {
this.view.showProgress()
}
.subscribe {
this.view.hideProgress()
this.view.displayNotes(it)
}
}
//in test:
@Test
fun load_notes_from_repository_and_display(){
val loadCallback = slot<(List<Note>)->Unit>();
every {
notesRepository.getNotes(capture(loadCallback))
} answers {
//Observable.just(FAKE_DATA)
loadCallback.invoke(FAKE_DATA)
}
notesListPresenter.loadData()
verifySequence {
notesListView.showProgress()
notesListView.hideProgress()
notesListView.displayNotes(FAKE_DATA)
}
}
Run Code Online (Sandbox Code Playgroud)
我得到了错误:
Verification failed: call 2 of 3: IView(#2).hideProgress()) was not called.
那么,如何在 Android 单元测试中使用 Mockk 测试 Rx 的东西呢?提前致谢!