android-test icon indicating copy to clipboard operation
android-test copied to clipboard

Not able to open and test login screen UI functionality using espresso in android app

Open AbhishekArrk opened this issue 3 years ago • 0 comments

Description

I am trying to test login screen UI functionality through espresso

How can i mock activity as it requires to activity to be launched before testing.

Steps to Reproduce

i am initializing the aws in my activity override fun onCreate(savedInstanceState: Bundle?) { (application as App).getAwsSessionComponent().inject(this) }

Expected Results

Login screen to be opened for testing

Actual Results

AWS initialization failed. I don't want to initialize AWS how can i mock activity or let me know a way to open login screen and test it.

AndroidX Test and Android OS Versions

Android OS ver12

Code for UI testing

`@RunWith(AndroidJUnit4::class) class LoginActivityTest{

@Rule
@JvmField
var activityTestRule: ActivityScenarioRule<LoginActivity> =
    ActivityScenarioRule(LoginActivity::class.java)

@Test
fun testLoginSuccess() {

    onView(ViewMatchers.withId(R.id.edittext_login_email))
        .perform(typeText("[email protected]"))
    onView(ViewMatchers.withId(R.id.edittext_login_password))
        .perform(typeText("pwd123"))
    onView(ViewMatchers.withId(R.id.button_login))
        .perform(click())
}

}`

AbhishekArrk avatar Jul 25 '22 12:07 AbhishekArrk