End to End testing of android app
End-to-End Testing
End-to-End test are sometimes called black box tests becoz this test is written without knowing about the implementation. It only checks the outcome is right given the input.
In Android, Espresso is the greate tool for such kind of testing.
Example of Espresso Statement:
onView(withId(R.id.taskdetail_checkbox))
.perform(click())
.check(matches(isChecked()))
Espresso allows you to interact with the UI and then check that the UI state has been updated. Espresso has synchronization mechanisms built in so that you don't need to write any code to wait for the click to finish and for the UI to update.
From a black box testing perspective, you simply click the button and check that you're on the next screen. But between this two events, there's the possibility for a whole bunch of other events to occur. Especially synchronization mechanisms usually know to wait for these. But if you're doing something a little fancy and you end up jumping, to another co-routine or thread that espresso doesn't know about. You need to provide your own synchronization mechanism. This is done using Espresso Idling Resources mechanism.
Espresso Idling Resources
a synchronization mechanism which tracks whether the application is busy or idle for Espresso. The basic idea is that the idiling resources is an object that tracks whether the application is idle or is working.
- If the application is idle, Espresso knows it can continue testing.
- If the application is working, Espresso will wait untile idle.
So we will have to write application code, which uses idling resources to track whether the application is either idle or working. Then in our test we're going to register these idling resources so the Espresso can synchronize properly with the application.
Comments
Post a Comment