EasyMVP icon indicating copy to clipboard operation
EasyMVP copied to clipboard

EasyMVP and Robolectric annotations problem

Open bardss opened this issue 7 years ago • 0 comments

I have problem while trying to use Robolectric to test activity which is using EasyMvp. All of the classes are written in Kotlin.

Part of Activity:

@ActivityView(layout = R.layout.activity_access, presenter = AccessPresenterImpl::class)
class AccessActivity : BaseActivity(), AccessView {

@Presenter
lateinit var presenter: AccessPresenter

override fun providePresenter(): BasePresenter? {
    return presenter
}

I was trying to introduce Robolectric tests in my app.

var activity: AccessActivity? = null
var loginEditText: EditText? = null
var passwordEditText: EditText? = null

@Before
fun initData() {
    activity = Robolectric.setupActivity(AccessActivity::class.java)
    loginEditText = activity?.findViewById(R.id.loginEditText)
    passwordEditText = activity?.findViewById(R.id.passwordEditText)
}

But while Running the test, I am always getting error:

kotlin.UninitializedPropertyAccessException: lateinit property presenter has not been initialized I tried numerous of ideas like changing presenter to nullable object, but EasyMVP do not compile with it.

Any solution for that?

bardss avatar Jan 14 '18 15:01 bardss