Sergio Crespo Toubes
11/08/2019, 8:58 AMfun loadData = MainScope().launch {
view.showProgressDialog()
// load data
}
Given(""){
When(""){
runBlocking {
withContext(Dispatchers.Main) {
presenter.loadData()
}
}
Then("show progress dialog") {
verify(exactly = 1) {
view.showProgressDialog()
}
}
}
}
I am loading coroutines with this way
val mainThreadSurrogate = newSingleThreadContext("Main thread")
override fun isolationMode(): IsolationMode = IsolationMode.InstancePerLeaf
override fun beforeSpec(spec: Spec) {
super.beforeSpec(spec)
Dispatchers.setMain(mainThreadSurrogate)
}
override fun afterSpec(spec: Spec) {
super.afterSpec(spec)
mainThreadSurrogate.close()
}
wasyl
11/08/2019, 10:38 AMGiven("")
and When("")
? What if you tried putting two different, non-empty strings there?Sergio Crespo Toubes
11/08/2019, 10:39 AMSergio Crespo Toubes
11/08/2019, 10:39 AMLeoColman
11/08/2019, 1:13 PMRunBlocking
inside the test?Sergio Crespo Toubes
11/08/2019, 1:15 PMSergio Crespo Toubes
11/08/2019, 3:12 PMLeoColman
11/08/2019, 3:14 PMsuspend
added to them, so they run in a coroutine context alreadySergio Crespo Toubes
11/08/2019, 3:14 PMSergio Crespo Toubes
11/08/2019, 3:14 PMLeoColman
11/08/2019, 3:15 PMSergio Crespo Toubes
11/08/2019, 3:16 PMsuspend When(""){}
?LeoColman
11/08/2019, 3:17 PMRunBlocking
inside your When
Sergio Crespo Toubes
11/08/2019, 3:24 PMSergio Crespo Toubes
11/08/2019, 3:27 PMLeoColman
11/08/2019, 3:28 PMLeoColman
11/08/2019, 3:28 PMsam
11/08/2019, 4:09 PMsam
11/08/2019, 4:09 PM