[android-developers] Re: Mocking static classes like Enviroment

2011-06-15 Thread Sunil Chandra
Hi All, I am pretty new to Android and trying to write an application that stores some data on external storage. I figure that Environment.getxxxState are the functions to check before assuming their presence. Now, since these are system enforced objects, how do I mock them for testing

[android-developers] Re: Mocking static classes like Enviroment

2011-06-15 Thread Kyle Szklenski
Typically, this isn't done by mocking those classes directly, but rather by wrapping those classes in interfaces and then mocking said interfaces. For example, consider the following code (I'm not claiming this is good code - just a way to use and fix things that you're trying): public