How to use arraymap in the code of JUnit (non institutional) Android unit test?

If an unchecked unit test (not subclassed from androidtestcase) calls code using arraymap, it will be in XX xx. The notorious method XXX is encountered in XX instead of an impersonation error (see http://tools.android.com/tech-docs/unit-testing-support#TOC -Method-…-not-mocked.-).

In many cases, the best solution to this error is to compile the package containing the problematic class directly into the test target, such as Using JSON, add to build. Exe gradle:

testCompile 'org.json:json:20160212'

I don't know any way to use arraymap, because unlike JSON, it is actually part of the Android source code I don't think it's externally available (I can't find it on jcenter)

Any ideas? I don't want to run slow Android (instrumented) tests on the simulator to test model layer classes that happen to use basic collection classes (and it looks crazy to simulate their methods!)

Solution

The best work I can think of is to use common collections like Apache, where they implement maps, such as their hasedmap It's a little stupid to have to include another library to do such a simple thing

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>