0

In the way it works on Eclipse for Android development, yuo can easily :

  • create a library project, and then no apk will be generated but rather a jar that will be added as dependency to apps that will use the library
  • create an android project and rather easily create a test project for it, using Instrumentation test cases, etc..

This works pretty well. But how do you provide unit and functional tests for an android librairy ?

As soon as I turn my library-project into a library through eclipse then, it's not testable any more as no apk is generated, no apk is installed on the device to be instrumented by the test app.

And more over, if my lib needs some permissions, an app using the lib can add the permissions to its manifest, but a testing app can't do that ! The testing framework instruments the tested app using the permission declared by the app under test, not the testing app.

An obvious answer would be not to unit test the library itself, but to test a sample app using the library but we are far from unit tests...

Thanks in advance, folks !

A more detailled aspect of this problem can be found here.

Community
  • 1
  • 1
Snicolas
  • 37,840
  • 15
  • 114
  • 173
  • If people are interested in this question, feel free to comment or add new answers. The question is somewhat still open as it seems there is no real good solution to test a librairy in android framework yet. – Snicolas Jan 20 '12 at 08:01

1 Answers1

0

The solution you suggest at the end is the one that we've been using. We create a library and a simple program that just loads up the library. Early on we just ensure that everything builds and works as expected, but you can then add unit tests to the simple, non-library program.

Sorry, in our experience, that is the best way.

Mike Buland
  • 631
  • 4
  • 5
  • we did that too, but we are not fully satisfied with this approach as it tends to mix sample app testing and librairy testing. But thx for answering – Snicolas Jan 20 '12 at 08:01