Motivation
How can i autotest the UI ?
Solution
Espresso
- very simple functionality : onView\onData->perform->check
- ViewMatchers : withId , ...
- ViewActions : click , typeText , pressKey , clearText
- ViewAssertions : matches(Matcher) , ....
- you can check that the view has a text
- Top 5 Android Testing Frameworks and the latest
- you can do the following :
Espresso runs under "androidTest" i.e. under Device\Emulator.perform(click()) // click() is a ViewAction .check(matches(isDisplayed())); // matches(isDisplayed()) is a ViewAssertion
- onView(withId(R.id.my_view)) // withId(R.id.my_view) is a ViewMatcher
- notice 3 operations : 1. get view 2. perform operation 3. check result
Espresso with intents
suppose i have activity which return info - how can i test it ?
looks like the following link has the answer - here
Questions :
- More solutions ??
- Does it run inside JUnit
- how to check layout order
Reference
- https://codelabs.developers.google.com/codelabs/android-testing/index.html?index=..%2F..%2Findex#0
- very good and also includes Dagger
- http://blog.sqisland.com/2015/04/dagger-2-espresso-2-mockito.html
- http://google.github.io/android-testing-support-library/docs/espresso/index.html
- Testing a single app - Android Development
- AndroidTestingEspresso - YouTube - looks very good
- sample Espresso test - YouTube
- AndroidTestingEspresso - Vogella
Nathan
No comments:
Post a Comment