Android Application Testing Guide by Diego Torres Milano


Summary: The only introduction to Unit Tests for Android

Recently I have fallen for Unit Testing. They are really cool. However, it is very hard to find good books covering this topic. When it comes to Android, it is even harder. Check out any on-line store. It will turn out that this book is the only one that covers this topic. Diego tries to provide you with the basic knowledge related to application testing at Android platform. At first chapter, you are presented various kinds of tests: Unit Tests, Mock objects and UI Tests, Integration tests, Functional tests, System test, Instrumentation, etc. Each of them are slightly different from others thus it is good to know what part of software development they cover. Second chapter covers different aspects of tests execution. You will learn here how to start test for single file for the whole suite, how to group tests using annotations and eventually, how to start tests from command line. At first glance, running tests from command line might seem to be not quite good idea – after all, you have an IDE. However, this may allow you to integrate test phase into your auto building process. This way, you can have your code build and tested at the same place. Third part makes you familiar with assertions and mock objects. Assertions make a lot of troubles for newcomers because they are slightly unintuitive at the very beginning. Diego explains this topic quite easily and provides description of most common used assertion related methods. Mock objects are something different. They allow you to pretend the actual objects. This is quite important especially in case of database related testing. Fourth chapter is devoted to Test Driven Development. This approach is really cool. At first it looks slightly awkward – you have to write something that tests things that do not exist. However, after you start using it, you won’t be able to imagine any other way of development. Well, I exaggerate a little bit, but there is part of true in this statement. Keep in mind that each approach has its flaws and there is no silver bullet, how Mr. Brooks used to say. TDD may not be applicable to your particular use case. But still, it is worth considering. Chapter eight covers very interesting topic related to continuous integration. In any sufficiently large project it is more than required to have continuous integration provided by automatic build and automatic test processes. One issue here is that this topic is not covered very extensively. If you read the book, it might look like a quite easy thing to do. Believe me it is not. Usually it turns out that you have lots of exceptions from the general build rules and you have to deal with them. However, this is nice introduction to the topic. Profiling is not covered perfectly as well. This is a biggest issue of all the books that cover testing related contents. They tend to show you how to measure things but they doesn’t explain how to interpret them. In fact it may end up with using R and some statistic related topics to get things well interpreted.

Drawbacks? There are always some. I think, in case of this book there are few but these are not the major flaws for the content. Book is slightly outdated, it doesn’t cover most recent release of Eclipse and Android related SDKs. If you will use most recent Android SDK and most recent Eclipse release you will definitely be abel to tell the difference. Sometimes it is hard to follow the book because of these small differences. For example, you will notice that screen shoots represent something different from what you see on your screen. However, Diego provides you with detailed configuration he has used during book composition, this way you can install everything that is needed and you can configure environment exactly the same way as Diego did – this is a big plus for the author. Another issue are missing, so called, flavors of the topic. I miss here detailed description of how to test mock data from the database. This is really big topic. And it looks like everybody avoids it. How to create sample data, how to create good database related tests, how to combine artificial and real data during development. Diego doesn’t cover this topic, however as an excuse for the author, I can say that there are very few places you can find description of this issue.

Product page:

Packt: http://www.packtpub.com/android-application-testing-guide/book
Amazon (in Books): Android Application Testing Guide
Amazon (Kindle): Android Application Testing Guide