Android development

I’ve only recently started coding Android apps but I’ve started to put together a set of pages describing how I’ve overcome some of the problems I’ve encountered.  I hope they’ll be useful to other developers.

Posted in Code | Tagged , , | Leave a comment

Unit testing – removing data dependency

So what’s the best way to stub out your data classes so that your business logic tests don’t break because they’re ultimately dependent on a test database over which you have little or no control?  Well DbUnit’s been around for a while and TestNG has a DataProvider annotation that might be useful.  But I haven’t found anything that uses the instrument package introduced in JDK1.5 despite the fact that it presents the opportunity for a really simple solution.  The interface allows you to run some code prior to the main method and use that code to re-define classes.  So you build against your actual data classes but execute your tests against replacements that don’t go anywhere near a database.  Dive in by downloading this .zip file and looking at readme.txt; the structure’s covered in the diagram below.

I think this gives really good value: maximum control for minimal configuration and a few lines of code.  I also think it slots in with any of the test frameworks you might already be using.

Posted in Code | Tagged , | 3 Comments