title: Android Unit Testing / Mockito: android.location.Location not mocked
body: <p>I am trying to learn basic JUnit and Mockito testing on Android. I'm trying to write unit tests for a simple class that handles finding the user's location from Location Services on behalf of activities that need location information.</p>
  
  <p>I have been trying to create "faked location" to test with:</p>
  
  <pre><code>@Test
  public void testLocationReceived() throws Exception {
      Location fakeLocation = new Location(LocationManager.NETWORK_PROVIDER);
      fakeLocation.setLongitude(100);
      fakeLocation.setLatitude(-80);
      ...  
  }
  </code></pre>
  
  <p>But I get the error:</p>
  
  <pre><code>java.lang.RuntimeException: Method setLongitude in android.location.Location not mocked.
  </code></pre>
  
  <p>I understand that unit tests on Android run on the JVM, so you don't have access to anything that requires the operating system / framework, but is this one of those cases as well? </p>
  
  <ul>
  <li>If so, how do you tell what classes can / can't be used on the JVM?</li>
  <li>Do I now need instrumentation/device tests in addition to
  JVM-based unit tests just to test this one class?</li>
  </ul>