I'm trying to understand how should I test my app, I'm still learning with mockito
I also saw mockk
but couldn't make it work, this is my Presenter
class MyPresenterImpl @Inject constructor(var myUseCase: MyUseCase) : MyContract.Presenter {
private var mView: MyContract.View? = null
private var disposable: Disposable? = null
override fun attachView(view: MyContract.View) {
this.mView = view
this.mView?.showProgressBar(true)
}
override fun loadResults() {
disposable = getList.execute()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{ result ->
mView?.showProgressBar(false)
mView?.showResults(result)
},
{ error ->
mView?.showProgressBar(false)
mView?.showError(error.localizedMessage)
})
}
override fun rxJavaUnsuscribe() {
if (disposable != null && !disposable!!.isDisposed) {
disposable!!.dispose()
}
}
override fun detachView() {
this.mView = null
}
}
How I'm supposed to test this presenter? Do I have to add all of these methods?
I was trying to do it with mockito
but I also can use mockk
.
And some people told me that I have to do something with Schedulers
and use the trampoline
one but it's not clear for me could anyone of you provide an example or explain it a little bit?