A little while ago I wanted my unit test results for my Android apps that I build with Hudson. I tweeted about it, but forgot to follow up with some more details, so here it is.
Since I the default android testrunner does not output it’s format in a xml suitable for Hudson, I decided to dig around and after looking at source for InstrumentationTestRunner I came up with this.
The com.neenbedankt.android.test.InstrumentationTestRunner extends the Android one so that an xml of the test results is written to the device when running the tests. To use this in your Hudson build you only have to take these simple steps:
- Add the testrunner to your project, and reference it in you AndroidManifest.xml (see here)
- Startup an emulator in your Hudson build using the android emulator plugin and launch adb to run the tests
- Pull the generated xml report file from the device and put it somewhere in your build dir so that Hudson can find it.
If all goes well, Hudson will pick up the results and use that to show the JUnit results.
For my own little projects it seems to work fine, although it I’ve implemented the bare minimum to get something working in Hudson.