jasmine.framework.test.mockito.MockUtil Maven / Gradle / Ivy
package jasmine.framework.test.mockito;
import jasmine.framework.common.util.CheckUtil;
import org.mockito.Mockito;
/**
*
* 模拟工具类。
*
*
* @author mh.z
*/
public class MockUtil {
/**
* 模拟对象
*
* @param classToMock
* @param mock
* @param
* @return
*/
public static T mock(Class classToMock, CustomMock mock) {
CheckUtil.notNull(classToMock, "classToMock null");
CustomAnswer answer = new CustomAnswer<>();
T target = Mockito.mock(classToMock, answer);
if (mock != null) {
answer.mock(target, mock);
}
return target;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy