开发者

How can I test a library on Android? [duplicate]

开发者 https://www.devze.com 2023-01-07 05:53 出处:网络
This question already has an answer here: Simplest way to 开发者_如何学运维unit test an android library application?
This question already has an answer here: Simplest way to 开发者_如何学运维unit test an android library application? (1 answer) Closed 9 years ago.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消