mardi 26 avril 2016

Using Android SDK classes in unit tests

I started creating unit tests for my Android project. I understand the difference between unit tests and instrumentation tests.

In my code I use android SDK's android.location.Location class. This class is used to represent a Geo location and as such is used extensively even in very fundamental classes of my application.

That causes an issue when trying to unit test on the JVM. for instance a method which uses the getBearing() method, fails to run on the JVM and throws this exception:

java.lang.RuntimeException: Method setLatitude in android.location.Location not mocked.

Is there a way to add that class only to the unit test which will enable it to run on the JVM? Is there another\smarter solution?

Aucun commentaire:

Enregistrer un commentaire