Sunday, April 24, 2011

Test - first development for Android

My app (Reverse CheckList) is now officially big enough to get over it and start having some unit tests. Seriously.

How can I tell?

For the first couple of hundreds of SLOC it was easy - a few features, easy to test, easy to keep the entire thing in my head. Features were not interdependent, and the whole app was just a test field for code samples that I found online. Oh, and it was not released. My wife and I were the only users. So if something did not work, I could simply code a fix and re-deploy it to our phones. Piece of cake.

This all changed when the design started crystallizing, when I refactored some of the code, that was previously scattered across multiple code files to be more coherent and reusable, and finally, when I released the app to the Android Market.

Reusable components... I think everyone agrees with me that this is a great idea to write code once and then reuse it. No code duplication, better design and... more dependencies! Yes! If a method is called from one place, you only need to retest this one place. If it is called from multiple places, then you have a bigger problem on your hands.

 Monkey helps a lot, of course. Just because 1. I'm too lazy to re-test the entire app when I change something 2. IT IS AWESOME and I can spend hours watching it just randomly click on stuff (Sometimes on two emulators simultaneously), but now I feel that even that is not enough.

So unit tests it is. We'll see how it goes.

No comments: