How to mock Context using Mockito?

前端 未结 3 1090
迷失自我
迷失自我 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:05

    If you want to get the context with Kotlin and Mockito, you can do it in the following way:

    mock(Context::class.java)
    

提交回复
热议问题