Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Library Projects and Unit Testing [closed]

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.

like image 797
Mike D Avatar asked Jul 19 '12 19:07

Mike D


2 Answers

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.

like image 121
Leszek Avatar answered Sep 19 '22 17:09

Leszek


What this answer mentions in an update is probably what's explained step-by-step here.

like image 28
Diego Torres Milano Avatar answered Sep 18 '22 17:09

Diego Torres Milano