日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

java junit 私有方法_有没有办法在Junit5中的另一个方法中模拟私有方法调用

發(fā)布時(shí)間:2025/3/15 52 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java junit 私有方法_有没有办法在Junit5中的另一个方法中模拟私有方法调用 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

下面是我想測試的方法,但據(jù)我所知Junit5不支持PowerMockito。那么有什么方法可以在另一個(gè)方法內(nèi)部模擬私有方法調(diào)用嗎?

public Class MyClass {

private void sendEmailNotification(Checklist Checklist){

EmailService emailService = new EmailService();

BaseDTO esDO = newFolderService.getFolderByUri(ServicesUtils.getDecodedCaseNodeUriFromSelfLink(Checklist.getEs_uri()));

String esName = esDO.getName();

SharedInfo sharedInfo = Checklist.getShared_info();

sharedInfo.setEng_space_name(esName);

String reviewer = Checklist.getReviewer();

String ChecklistUri = Checklist.getUri();

String ChecklistName = Checklist.getName();

String targetPhase = Checklist.getTarget_phase();

String comment = Checklist.getComment();

String submitter = Checklist.getSubmitter();

String appURL = Checklist.getShared_info().getApp_url();

String ChecklistLink = buildChecklistURL(appURL, ChecklistUri);

String emailBodyTemplate;

String emailSubject;

emailBodyTemplate = EmailTemplates.getEmailTemplateByName(EmailConstants.TEMPLATE_DELIVERABLE_ACCEPTED_REJECTED_WITH_COMMENTS);

emailSubject = String.format(EmailConstants.ACCEPT_REJECT_WITH_COMMENTS_SUBJECT, ChecklistName, targetPhase);

emailBodyTemplate = EmailTemplates.replaceSharedVariable(emailBodyTemplate, sharedInfo);

emailBodyTemplate = EmailTemplates.replaceVariable(emailBodyTemplate, EmailConstants.VAR_TARGET_PHASE, targetPhase);

emailBodyTemplate = EmailTemplates.replaceVariable(emailBodyTemplate, EmailConstants.VAR_REVIEWER, reviewer);

emailBodyTemplate = EmailTemplates.replaceVariable(emailBodyTemplate, EmailConstants.VAR_CHECKLIST_ITEM_NAME, ChecklistName);

emailBodyTemplate = EmailTemplates.replaceVariable(emailBodyTemplate, EmailConstants.VAR_COMMENT, comment);

emailBodyTemplate = EmailTemplates.replaceVariable(emailBodyTemplate, EmailConstants.VAR_CHECKLIST_ITEM_URL, ChecklistLink);

try {

emailService.sendEmail(submitter, EmailConstants.EMAIL_SENDER, emailSubject, emailBodyTemplate);

} catch (RuntimeException e) {

Checklist.addError(messages.get(E_ACCEPT_REJECT_SEND_EMAIL));

}

}

//Method to be tested

public void method(Checklist checklist){

/*Some Code*/

sendEmail(checklist); /* want to ignore this, as throwing NullPointerException*/

/*Some Code*/

}}

總結(jié)

以上是生活随笔為你收集整理的java junit 私有方法_有没有办法在Junit5中的另一个方法中模拟私有方法调用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。