This is an example project used in my talk at the JavaZone 2011 conference to show how Android JUnit tests can be ran on a CI server like Jenkins. The tests will run on an actual device or the Android emulator.
A custom ant target is created to run the tests (ant run-tests) and pull the XML report from the device. The InstrumentationTestRunner.java that creates XML reports on the device is part of the nbandroid project.
Slides are available at SlideShare
If you have any questions, feel free to ask them here in the comments field or at http://twitter.com/sveinungkb.
Folder Target Description
jz.test test-and-pull-report Will run all unit tests and pull JUnit XML report
(that can be used in Jenkins/Hudons) from device/emulator
jz.test run-tests Runs the unit tests in the test project
jz.test coverage Runs the unit tests and records test coverage using Emma
jz install Compiles and installs the application on dev/emulator
jz release Will sign and release your application, perfect
for automatic building!
This is the file containing the custom ant target test-and-pull-report that will run the unit tests and pull the results from the device.
The file for shared build properties for the test project (this one you want in your CVS, local.properties you ignore), important here is the test.runner property that ensures that our InstrumentationTestRunner is used during testing.
Test project's manifest, note the reference to our custom test runner.
No customization done in this proejct, but custom build targets can be added, very useful for repeated building.