I have been trying in vain and everytime I am just reaching a dead end.
I am trying to look for a way to stub network responses with my json similar to cy.intercept
in cypress using mockwebserver
and espresso
This is my code
@Test
fun loginwithincorrectpassword(){
mockWebServer.enqueue(MockResponse().setBody("{\"success\":false,\"message\":\"Your emccail or password is incorrect. Use ‘Forgot Passddword’ option below to reset\",\"errorCode\":1019}"))
val intent = Intent()
activityRule.launchActivity(intent)
mainActivityTest.bypassPushnotification()
mainActivityTest.bypassWalkthrough()
onView(withId(R.id.login_pass_continue_btn)).perform(click())
onView(withText("Your email or password is incorrect. Use ‘Forgot Password’ option below to reset")).check(matches(isDisplayed()))
onView(withText("OK")).check(matches(isDisplayed())).perform(click())
onView(withId(R.id.login_pass_password_edt)).perform(clearText())
}
class Login {
val mainActivityTest = MainActivityTest()
val mockWebServer = MockWebServer()
@Before
@Throws(IOException::class, InterruptedException::class)
fun setup() {
mockWebServer.start(8080)
}
@Rule
@JvmField
var activityRule = ActivityTestRule<SplashActivity>(
SplashActivity::class.java, true, false
)
I am not sure if I am going on the right direction, I had referred to several materials but kind of dumb in not getting it. Need help in proceeding forward.