This post is about setting up android emulator for UI test automation. Properly configured emulator is the basis for reliable tests. Hundreds or thousands of professionally written test cases is great but if they become flaky because of the environment they are running on, their value reduces a lot. I will give you a couple of advices I'm following in my test automation projects. In general we will go through below topics: Managing emulator system animations Controlling soft keyboard appearance Changing emulator system locale Tweaking first and second points will reduce to minimum flakiness in our automated tests which can be caused by emulator. For those who are lazy to read the whole article at the bottom of the post I shared youtube video where I describe the same points with one more additional hint on top :) 1. There are three types of system animation we may control: window animation scale transition animation scale animator duration scale Emulator
Recently I had a need to adapt my Espresso tests to operate on RecyclerView after migration from ListViews. The current actions that are available for RecyclerView based on item position working fine but I don't like to be dependent on position since data in my tests is created dynamically. I've googled the ViewHolder matchers and found only this link without any practical examples - RecyclerViewActions . Then based on already created Matcher<Object> used in onData(...) I've created Matcher<VH> which was not so difficult. Let's assume each item in RecyclerView adapter has subject, represented by TextView. The below matcher will search for item in RecylerView with unique subject which I provide into matcher. Feel free to use it: public static Matcher<RecyclerView.ViewHolder> withItemSubjectInViewHolder(final String itemSubject) { Checks.checkNotNull(itemSubject); return new BoundedMatcher (RecyclerView.ViewHolder, MyListRecyclerViewIt