android-test
android-test copied to clipboard
Not able to open and test login screen UI functionality using espresso in android app
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())
}
}`