In the middle of a method I'm doing something like this
JSONObject = new JSONObject(json);
Now I'm trying to unit test that using Android Studio
and JUnit
. Unfortunately, Android Studio won't let me create a real JSONObject
instance and ask me to mock it.
What's the simplest way to keep that code and being able to unit test?
Mockito
won't help me since it's not able to mock constructors, but it seems PowerMock
is the way to go.