How to unit test Log.e in android?
问题 I need to perform an unit test where I need to check if an error message is logged when a certain condition occurs in my app. try { //do something } catch (ClassCastException | IndexOutOfBoundsException e) { Log.e(INFOTAG, "Exception "+e.getMessage()); } How can I test this? I am getting the below error while unit testing. Caused by: java.lang.RuntimeException: Method e in android.util.Log not mocked. 回答1: There are two ways to do this: You turn to Powermock or Powermokito; as those mocking