我需要测试的方法是 public 方法:
public ResponseResult subscribe(SysSubscription sysSubscription) throws JsonGenerationException, JsonMappingException, IOException {
LOGGER.debug("=====================subscribe Subscription=======================");
ResponseResult result = new ResponseResult();
if (checkNotNull(sysSubscription)) {
return handleSubscribe(sysSubscription, result);
}
return result;
}
但是在handleSubscribe内部会调用 private 方法:
private ResponseResult createResponseResultByResponse(Response response, ResponseResult responseResult) {
试了 powermockito spy 来 partially mock private 方法发现没用。 因为这是两层的public 方法。
只好把方法改成
protected ResponseResult createResponseResultByResponse(Response response, ResponseResult responseResult) {