I am developing an Android library for interacting with a web service, and I am trying to develop some unit tests to check how well this works.
When I run the specified tests, I get the following error:
[2012-07-19 15:12:09 - MMWebAPI] Could not find MMWebAPI.apk!
[2012-07-19 15:12:10 - MMWebAPITest] Test run failed: Unable to find instrumentation target package: com.webapi.mmwebapi
Where the MMWebAPI
is the library, and does not produce a .apk
.
I am looking for definitive guide for unit testing Android projects, specifically, what can and can not be tested (in this case, network operations are the core of the library), a step by step tutorial would be a great help also.
Android testing framework doesn't allow to test Android library without application project that depends on that library. Please look at this answer.
You can find good introduction to testing Android project here. If your code doesn't use android-specific method You can use JUnit for tests + some mocking library. Among other testing framework Robotium and Robolectric seems to be most popular.
What this answer mentions in an update is probably what's explained step-by-step here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With