If an uninstrumented unit test (not subclassed from AndroidTestCase) calls code that uses an ArrayMap, it hits the infamous Method xxx in xx.xx.xx not mocked error (see http://ift.tt/1NBEu0w).
The best solution to this error in many cases is to compile the package containing the problematic class directly into the test target, eg. with json, adding to build.gradle:
testCompile 'org.json:json:20160212'
I don't know of any way to do this with ArrayList, as unlike json it's actually part of the Android source. I don't think it's available externally (I haven't been able to find it on jcenter).
Any ideas? I don't want to run slow Android (instrumented) tests on the emulator just in order to test model layer classes that happen to use basic collection classes (and mocking their methods would seem insane!).
Aucun commentaire:
Enregistrer un commentaire