How can I test a library on Android? [duplicate]
I'm developing a library, not an application, for Android and I would like to know how should I test it? I know that if you are developing an application you can instrument the test+application and make it work, but this is not my case. I'm using Maven. Is it possible integrate the test results to the Maven lifecycle? The worst case would be create an application to test my library.
Thoughts?
Try not having android runtime dependencies. Then you can run your tests in a JRE. Sometimes you need only compile time dependencies and can mock the things of the runtime you need.
The recommended way to test Android apps as described here, is to have a seperate project with the tests. I assume you are using the maven-android-plugin. If you do you can deploy your library as an otherwise empty app and execute the tests in your test-project with the android:instrumentation goal.
精彩评论