How to mock Context using Mockito?

前端 未结 3 1091
迷失自我
迷失自我 2021-02-11 19:44

I\'m using Context to access system level services like WifiManager and BluetoothManager. How to mock this getApplicationContext() using Mockito?

3条回答
  •  太阳男子
    2021-02-11 20:20

    Let's have a look at the following class: MockContext

    If you need more insight, check the Official Testing Fundamentals page

提交回复
热议问题