Android Unit Testing - Best Practice when code references android classes

Viewed 2695

I have a regular JUnit Test Case that tests non-android method logic. The method uses TextUtils for things like TextUtils.isEmpty().

It doesn't make sense to me to make it an AndroidTestCase just to pull in TextUtils class. Is there a better way to instrument this unit test? Like add an android.jar to the test project or something?

Similar situation with another test where I want to mock a Context object. I can't mock it without making it extend AndroidTestCase. What is the best practice in these situations where I'm just trying to test non-android logic and don't want it to run on an emulator, yet it touches some android classes?

Thank you

2 Answers
Related