I am trying to write a JUnit for the below code but I am not getting any idea how to cover the code which is written in the catch
block statement. Please can anyone write a sample JUnit for the below code?
Here I don't want to cover any exception since this block never throws any, but want to cover the lines of code written in the catch block using Mockito. Basically, the catch block is unreachable in this case.
public void someMethod(Activity activity) {
try {
Log.d("TAG", "Print: " + activity);
} catch (Throwable e) {
e.printStackTrace();
}
}