Test-driven development (TDD) is a software process, whose aim is developing features by first introducing new failing test cases, and then writing the correspondent piece of code to make them pass.
Although theoretically fascinating, we all know how hard and how much hassle is required to adhere to this process. This becomes even trickier in Android, where current tools do not always empower devs to mock and stub properly the internals of the system.
In this talk, after recalling some of the basic principles of TDD and testing (e.g., mocking, stubbing), I am going to discuss how to introduce proper testing into a previously poorly tested project so to make it ideal for TDD. As a real-world example, I will consider code extracts from Grab’n Run (grabnrun.org), an open-source Android library that I developed to secure dynamic code loading, and that I heavily refactored during the past months.
Along the way, I will present some of the Java and Android-specific tools and frameworks (e.g., Mockito, Hamcrest, Robolectric, Shadows) for improving test efficacy, as well as share some of the lesson learned during the whole process.
Ideal targets for this talk are beginners, and intermediates in the subject of testing in Java and/or Android, who should receive a quite complete overview on the topic. Experts are also invited to remove some dust from their knowledge, and, maybe, to share their experience such that your libraries and mine could be even more well-tested in the future!