Below is my private method in my DataTap
class and I am trying to junit test this private method using jmockit -
private void parseResponse(String response) throws Exception {
if (response != null) {
// some code
}
}
So below is the junit test I wrote but for null case, it is throwing NPE somehow on the junit test itself.
DataTap tap = new DataTap();
Deencapsulation.invoke(tap, "parseResponse", "hello");
// this line throws NPE
Deencapsulation.invoke(tap, "parseResponse", null);
So my question is - Is there any way I can pass null string
to parseResponse
method using JMOCKIT as part of junit testing?
This is what I am seeing on that line -
The argument of type null should explicitly be cast to Object[] for the invocation of the varargs method invoke(Object, String, Object...) from type Deencapsulation. It could alternatively be cast to Object for a varargs invocation