Droidcon India chevron_right droidconIN 2015

Nazneen Rupawalla and Vidhi Thakrar - Where do the Android tests belong?

After looking at multiple android applications tests, we can see that most of them rely heavily on end-to-end tests, UI tests, and customer facing tests, rather than unit tests. This is a classic “inverted test pyramid”.
While most of the people know about this inverted test pyramid, there are challenges in writing tests at the unit level for Android apps because of the platforms’ architecture.

We too struggled with the right approach to test our application initially. We eventually figured out an approach by experimenting with different design patterns like MVP (Model-View-Presenter), MVVM and different testing frameworks like JUnit, Roboelectric, Espresso, Calabash.

In this talk, we will talk about our journey to achieve the ideal test pyramid structure. We will discuss the challenges we faced to test our apps and the approaches to overcome them with a working example.

At the end of the session, we will understand how to structure the code appropriately to unit test the logic and add tests at the appropriate layer.

Presentation Outline: 1) We will showcase a working Android application which will have features around components like database, network call and heavy UI like viewpager, etc. We will explain the importance of writing tests and test pyramid to maintain the stability of the project if we need to scale this application where more developers will be churning code.
2) We will look at listing the test scenarios of the application and discuss the levels these tests could be written in colloration with the inputs from the audience.
3) We will discuss the disadvantages of having so many tests at the functional level.
4) We will discuss the challenges we faced in our project because unit testing in Android does not come naturally and how we ended up with inverted test pyramid.
5) We will talk about our journey of trying different design patterns like MVP and MVVM.
6) We will build the same application by following TDD and will come up with a pattern which is a mixture of MVP and MVVM. We will test drive the functionalities and will showcase how to write tests at each layer of test pyramid on Android by using test frameworks like Junit and Espresso.

https://droidconin.talkfunnel.com/2015/55-where-do-the-android-tests-belong

More videos

video.title

Satish Patel - Unwrapping Android SDK Add-On

video.title

Vikram Aggarwal - Lessons from Android development at Google