by Nazneen Rupawalla (@nazneenr) on Sunday, October 18, 2015
View session in schedule
- Core Development - Full talk (45 minutes)
- Technical level
1) Understand how to overcome the “inverted test pyramid” issue in the application tests.
2) Understand how to test drive the logic while developing Android apps, by structuring the code appropriately.
3) Compare the existing test pyramid in the current application with ideal test pyramid and understand the kind of tests that fit in each layer while developing/testing Android apps.
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.
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.
APP SOURCE CODE - https://github.com/AndroidTestPyramid/GadgetStop
Nazneen is an Application Developer at ThoughtWorks. She has been into Android development for the last few years and has been involved in a wide variety of Android projects.
She has conducted four Android Bootcamps successfully for ThoughtWorks and has also been involved in code-jams for a local issue tracker application called Project Kranti. She has also been involved in developing event/conference applications for ThoughtWorks.
She has also been an active speaker in the Android community, and has spoken at various conferences including Mobile Developer Summit(MDS) 2013 and 2014.
Her article on Building Secure Android apps was published in PCQuest (May 2015).
She is an Android enthusiastic, always eager to explore and learn something new.
Vidhi Thakrar is a Senior Developer at ThoughtWorks and have almost 8 years of Experience in IT industry. She has mostly worked on various Mobile Platforms like J2ME, Blackberry and now working on Android. She is currently working for a leading US airlines mainly focusing on Android development.