Set parameters of android.location.Location object from JUnit unit test

Viewed 1074

I'm trying to make unit test for a function which receive android.location.Location object. But i blocked because i don't have possibility to set up parameters for Location object.

@Test
public void testLocation() {
    Location location = new Location("gps");
    location.setAccuracy(25F);
    location.setTime(5123L);
    System.out.println("Accuracy: " + location.getAccuracy());
    System.out.println("Time: " + location.getTime());
}

Output:

Accuracy: 0.0
Time: 0

Process finished with exit code 0

Location accuracy and time are zero but the values were set in code above. It's not an Intrumentation test, i'm running it as simple unit test under jvm (Test Artifact: Unit Tests).

Using JUnit 4.12

1 Answers
Related