How to mock Context using Mockito?

user3600801 picture user3600801 · Dec 3, 2015 · Viewed 39.5k times · Source

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

Answer

Sipty picture Sipty · Sep 13, 2017
    Context context = mock(Context.class);