Skip to content

EasyMVP and Robolectric annotations problem #45

Open
@bardss

Description

@bardss

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions