Issue
In my android app I need to get the country code of the current country. So i used the getNetworkCountryIso() method in android.telephony.TelephonyManager. Now I just want to test it with fake operator. I want to pretend that I'm in Us so that getNetworkCountryIso() will return "US" as my country. How can I do this ? Is there any app to fake operator like Fake GPS.
Thanks in advance !
Solution
I needed to mock TelephonyManager, ConnectivityManager and other stuff. We had trouble setting up mocking frameworks for Android. So we created a layer between TelephonyManager and our code. This layer(a class) had the same methods as TelephonyManager, and delegated all calls to actual TelephonyManager. But for testing we could substitute this "layer" with mock-layer that produced results we wanted. It adds a little unnecessary code but improved testability a lot!
Answered By - Taras
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.