The Clover for Android is in alpha stage and therefore it is not officially supported by Atlassian. The following page was created for all Clover-lovers who'd love to use our tool on the Android platform.
Please do not raise Android-related issues on Atlassian Support - instead of this add comments to this page or raise questions on Atlassian Answers - we will review them and try to help in spare time.
Feel free to download and use the experimental Clover-for-Android version. Feel free to contribute by extending this manual.
ShipIt days.We're proud to inform that Android support was initially created during one of our Atlassian
New to Clover?
If you haven't used Clover before, we strongly recommend spending few minutes to learn its basic features:
A prototype has been tested using following software versions, but it should work on other versions as well.
Note: Clover-for-Android is based on the Clover-for-Eclipse 3.1.7.
Note: Clover-for-Android is using 'adb' application to fetch coverage data from a device. It expects to find it in:
Please note that location of 'adb' has changed from <sdk>/tools to <sdk>/platform-tools since SDK v 8, so please don't use older SDK versions. Value of <sdk> is being fetched from 'com.android.ide.eclipse.adt.sdk' property in Eclipse Preferences ("Window > Preferences > Android > Android SDK").
Note: Clover-for-Android has been tested on a following configuration:
Clover for Android has following differences, compared to base Clover for Eclipse:
A following features were not tested on Clover for Android:
A following features do not work currently:
1) Run Eclipse and open your Android project.
2) Right click on the project, select "Clover > Enable on this project" from context menu.
3) Right click on the project, select "Properties > Clover". Toggle on "Enable Clover in this project". Next select "Custom value" radio button and enter a path to Clover database in a following format:
clover+remote:file:///<path to database file on desktop>?localCoverageDir=<path to coverage directory on device>
Click OK. All Clover views shall be added to current perspective. You can also open them from "Window > Show view > Other ... > Clover".
Possible InitString formats:
Keep in mind that for URIs:
: = %3A
\ = %5C
4) Change the flush policy to "At set intervals from a Clover thread" or "At set intervals" and define interval (1000 ms for example).
Note that when you close application on Android device, JVM is still running, thus the "At JVM shutdown ..." option is not preferred.
You can also trigger Clover flush programaticaly - just put "///CLOVER:FLUSH" inline comment in your code (for example in Activity.onDestroy() method).
5) Open "Project Properties > Java Build Path > Order and Export". You will find a CLOVER_RUNTIME library on a list. Enable the checkbox so that Clover library will be exported. Perform a full rebuild of the project. You should see "red coverage" in source files and in Coverage Explorer.
1) Select "Run as ... > Android application" from main menu or Package Explorer context menu. You can execute your application or unit tests on a real device or simulator. Choose device you wish to use.
There is no need to copy the clover.db to a device (yay!). Clover-for-Android is using a special coverage recorder version, which does not require presence of this database.
There is also no need to copy clover.jar to a device (yay!). Google Android Toolkit will automatically package CLOVER_RUNTIME jar file into Dalvik image during packaging.
Unit tests for Android are kept in a separate Eclipse project.
For such scenario we have found a following configuration which works:
Right click on the test project and select "Run as ... > Android JUnit Test". After tests are finished, select both projects in "Coverage Explorer" view and click "Refresh Coverage Data" button for each of them.
You shall see coverage results for both projects.
Unit tests are kept together with application code in one Eclipse project.
Configuration not tested yet.
Just click on the "Refresh Coverage Data" button
Clover is using "adb" command to retrieve coverage files from the default device. Make sure that you're running one device only, otherwise you might fetch coverage snapshots from wrong device.
As soon coverage data is fetched from device you can browse them using Coverage Explorer or Test Run Explorer view. It is also possible to generate HTML/XML/PDF reports, as usual.
When you click on the "Delete Coverage Recordings", Clover will remove files from desktop as well as from android device.
Clover is deleting coverage files from a location defined in initstring. In case when initstring has changed, you have to remove files manually - open the "File Explorer" view from "DDMS" perspective and navigate to a directory where coverage data was stored (usually it will be /data/data/com.my.application.name/clover).
Clover is using "adb" command to delete coverage files from the default device. Make sure that you're running one device only, otherwise you might delete coverage snapshots from wrong device.
Open "File > New ... > Project ... > Android > Android Sample Project" and click "Next". Choose "Android 2.3.3" build target and click "Next". Choose "Notepad" sample, name it "NotePad" and click Finish.
Right click on the project, select "Clover > Enable on this project" from context menu. All Clover views shall be added to current perspective. You can also open them from "Window > Show view > Other ... > Clover".
Open "Project Properties > Java Build Path > Order and Export". You will find a CLOVER_RUNTIME on a list. Tick the checkbox so that library will be exported.
Open "Project Properties > Clover". Set "clover+remote:file:///c%3A%5CTemp%5Candroid.db?localCoverageDir=/data/data/com.example.android.notepad/clover" initstring. Disable "Relative to project dir" checkbox. Set flush policy to "At set intervals from a Clover thread" with 1000 ms interval. Click OK.
Perform full rebuild. You should see red coverage in Coverage Explorer and text editors as on picture below.
Now let's run the application on Android device. Right click on the project, select "Run as > Android application". Wait few minutes until emulator starts and installs our app.
Add new notes, delete it, change title etc. Exit application.
Click "Refresh Coverage Data" button in Coverage Explorer view. After few seconds you shall see coverage data like on picture below:
You can browse coverage in IDE as well as generate XML/PDF/HTML reports, for example:
Prerequisite: "NotePad" project configured as in Example 1.
Open "File > New ... > Project ... > Android > Android Sample Project" and click "Next". Choose "Android 2.3.3" build target and click "Next". Choose "Notepad > tests" sample, name it "NotePadTests" and click Finish.
Right click on the NotePadTests project in Package Explorer. Open "Project Properties > Java Build Path > Projects". Add "NotePad" project to the list.
Click on the "Order and Export" tab, select NotePad checkbox. Click OK.
Open "Project Properties > Clover". Select "Enable Clover in this project" checkbox.
Set "clover+remote:file:///c%3A%5CTemp%5Candroid-tests.db?localCoverageDir=/data/data/com.example.android.notepad/clover" initstring. Disable "Relative to project dir" checkbox.
Set flush policy to "At JVM shutdown and on special instruction". Click OK and close Properties window.
Note that there is no need to export CLOVER_RUNTIME library, because it's already exported in the NotePad project.
Open NotePadTest class and add a tearDown() method like below:
Open NotePad/AndroidManifest.xml file and increase required API Level to 8 (it's required by ActivityInstrumentationTestCase2):
Perform full rebuild.
Right click on the NotePadTest project, select "Run as ... > Android JUnit Test" from context menu. Wait until tests are finished.
Select NotePad and NotePadTests project in Coverage Explorer and for each of them click on the "Refresh Coverage Data" button.
After few seconds you shall see coverage results similar to those:
In case of problems, you can search for more information in following places:
Open "Window > Preferences > Clover". Set "Clover plugin logging output level" to Debug or Verbose. Open Error Log console ("Window > Show view > Error Log"). You can track Clover messages like:
Open "Window > Open perspective > DDMS".
We are waiting for your feedback! Feel free to vote on implementing full Android support in: