What is the best way to write Espresso's test?


#1

Hello every boddy!
I want to ask you somethings…
I’m learning automation, in an Android project.
I’m using Espresso and Kotlin.

For example, I did the test verifyInvalidPass() that way:

    @Test
    fun verifyInvalidPass() {
        R.id.etUser.type("teste1")
        R.id.etPass.type("111")
        R.id.btnOk.click()
        "User or password does not match".verifyTextDisplayed()
    }

I did an Util class with that funcions:

fun Int.type(text: String) {
    onView(allOf<View>(withId(this)))
		.perform(scrollTo(), clearText(), typeText(text), closeSoftKeyboard())
		.check(matches(isDisplayed()))
}

fun Int.click(){
    onView(withId(this))
		.perform(ViewActions.click())
}

fun String.verifyTextDisplayed(){
    onView(ViewMatchers.withText(this))
		.check(matches(isDisplayed()))
}

What do you mean about it?
It is not exactly a Page Object Pattern, but look like better than just Espresso. I think it, although I’m beginer.
What would you do?