You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
private static <T> Class<T> getClassOf(T[] array) {
return (Class<T>) array.getClass().getComponentType();
}
/**
* Creates a mock object of type <var>typeToMock</var> and generates a name for it.
* @param <T> is the class of the mock
* @param reified don't pass any values to it. It's a trick to detect the class/interface you want to mock.
* @return the mock of typeToMock
*/
public <T> T mock(T... reified) {
if (reified.length > 0) {
throw new IllegalArgumentException(
"Please don't pass any values here. Java will detect class automagically.");
}
return mock(getClassOf(reified));
}
The text was updated successfully, but these errors were encountered:
Currently mock object is created as follows -
This can be created like below as well. We don't have to explicitly provide class name.
This is in reference to pull request mockito/mockito#2779 (comment)
Below code can be added -
The text was updated successfully, but these errors were encountered: