title: Robolectric fails from NullPointerException because of calls to storage
body: <p>I'm trying to start using unit testing with robolectric and am getting a NullPointerException when running even empty tests. In my apps application file I initialize my cache and it makes a call to the system storage which causes robolectric to freak out. Any information on how to circumvent this would be greatly appreciated.</p>
  
  <p>Here is the stack trace.</p>
  
  <pre><code>Java.lang.RuntimeException: java.lang.NullPointerException
      at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:228)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:168)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.junit.runners.Suite.runChild(Suite.java:128)
      at org.junit.runners.Suite.runChild(Suite.java:27)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
  Caused by: java.lang.NullPointerException
      at android.os.Environment.getStorageVolume(Environment.java:869)
      at android.os.Environment.isExternalStorageRemovable(Environment.java:756)
      at android.os.Environment.isExternalStorageRemovable(Environment.java:742)
      at com.*.*.ApplicationFile.getDiskCacheDir(ApplicationFile.java:131)
      at com.*.*.ApplicationFile.onCreate(ApplicationFile.java:87)
  </code></pre>
  
  <p>edit:
  getDiskCacheDir</p>
  
  <pre><code>public static File getDiskCacheDir(Context context, String uniqueName)
      {
  
          //Check if media is mounted or storage is built-in, if so, try and use external cache
          //otherwise use internal cache dir
          final String cachePath = Environment.MEDIA_MOUNTED
                  .equals(Environment.getExternalStorageState()) ||
                  !Environment.isExternalStorageRemovable() ? context.getExternalCacheDir()
                  .getPath() :
                  context.getCacheDir().getPath();
  
          return new File(cachePath + File.separator + uniqueName);
      }
  </code></pre>