Open source, coffee and us….


Unit Testing with Maven and Android

The default android development environment provides for testing applications using test applications that are deployed onto the target device and exercise the actual application within the android environment itself.  But what if you have non-android dependent code that you need to test without the overhead of a full build and deploy cycle (i.e. unit testing rather than integration testing)?

If you try and include unit tests in your standard application to fail the build prior to the apk being built or deployed you will need to make some significant changes to the standard ant build.xml in order to remove the test classes from the apk itself, and expose yourself to having to manage changes to the base build with new android versions.

Building the project using the maven android plugin makes the configuration for performing unit testing far simpler.  However, none of the provided samples show how to configure the unit tests particularly well, as they provide no unit test classes.

The main thing is to make sure that the build section specifies the testSourceDirectory, e.g.


You can then include jUnit (or testNg or other framework) to your test dependencies, and place unit test code under the test folder in the project root directory.  Running mvn test will now run all of your tests and halt the build if there are failures.

Note that in many cases tests will fail if there is any dependency on android classes at all (watch out especially for android.util.Log .  This can be overcome using Mock implementations, especially with tools such as jMockit, which allows mocking of final classes, static methods, partial mocking etc.

More of this later.

Cheap Pills in International Sites

Cheap Pharmacyviagra uk buy buy in Europe

Cheap Pharmacycialis uk


Onlinelasix online


Cheaporder cheap viagra

PurchaseDrugs no Prescription EUROPE
or herevalacyclovirbuy propecia ukviagra australia and you can see more here australia pharmacy generic