I am currently writing a UI test with espresso for an android activity. How to mock the result
variable in the below code?
As you can see the
Such that I can test the flow for the UI without calling the checkUser()
method because it gonna connects to the internet. I am using MockK
, but other mock frameworks are fine as well.
Thanks
package nz.salect.handset
import android.os.Bundle
import nz.salect.lib.auth.Auth
class HomeActivity : SalectActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_home)
val result = Auth().checkUser()
if (result.error) {
showError()
} else {
// do something else
}
}
}
Aucun commentaire:
Enregistrer un commentaire