Photo by Science in HD on Unsplash

Road to Android UI tests

Patxi Bocos

--

Writing stable and reliable UI tests is neither easy nor trivial. There are multiple factors applications depend on that UI developers can’t control. Network is a very common external dependency that can produce test instability. There are many reasons that make it hard to maintain a fully functional server side infrastructure:

  • Data consistency
  • Different application and server availability
  • Effort and cost of maintaining the above

A few months ago the Android team at my job decided to work on enabling UI tests. Writing tests itself is an “easy” task thanks to powerful tools like Espresso. But based on our past experience, this time we wanted to have robust, reliable and stable tests. The existing tests (existing but not running) were hitting a real (and non-production) environment. As mentioned before, this lead to unreliable tests.

So we changed the approach and decided to have the entire network layer mocked. What this means for native apps is that no network request to any environment will be performed.

🌍 Environment library

The first step towards making the app point to a given base url is to centralize every URL definition. To give some context, we have many backend services running on different layers that the app hits…

--

--

Patxi Bocos

Impure developer and functional programming enthusiast