Automated Android testing using Jenkins CI
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.
Important ant targets
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!
Important files
jz.test\build.xml
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.
jz.test\build.properties
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.
jz.test\AndroidManifest.xml
Test project's manifest, note the reference to our custom test runner.
jz\build.xml
No customization done in this proejct, but custom build targets can be added, very useful for repeated building.