Android: Unit testing Android applications with Robolectric and Mockito

后端 未结 4 1555
没有蜡笔的小新
没有蜡笔的小新 2021-02-19 22:20

I have a Java library that uses a few things from the Android APIs. I\'d like to use Mockito to write unit tests for this library.

Is there a way I can go about this? <

4条回答
  •  感情败类
    2021-02-19 23:00

    After much Googling, I have come across an answer for this here.

    Basically it involves using the Robolectric unit testing framework, which intercepts the loading of the Android classes. You can then go ahead and use Mockito (although it isn't necessary in most cases) and run your tests on the JVM!

提交回复
热议问题