【发布时间】:2011-09-22 06:27:29
【问题描述】:
我是 EasyMock 的新手。我需要使用 EasyMock 测试我的类,但这里的问题是我的类有内部类,并且这个内部类在外部类的方法中被实例化,并通过传递一些参数来调用内部类的方法。我不知道如何测试这个类。
下面是一些示例代码。
Any help or suggetions are highly appreciated.
public class ServiceClass implements ServiceInterface {
public void updateUSer(USer) {
//some logic over here.
sendEmailNotice(subject, vTemplate);
}
private sendEmailNotice(subject, vTemplate) {
MimeMessagePrepator eNotice = new PrepareEmailNotice(subject, vTemplate);
MailSender.send( eNotice );
}
public class PrepareEmailNotice implements MimeMessagePrepator {
// some local variables.
public PrepareEmailNotice(subject, vTemplate) {
subject = subject;
vTemplate = vTemplate;
}
public void prepare( MimeMessage message) {
MimeMessageHealper helper = new MimeMessageHealper(message, true);
// setting the mail properties like subject, to address, etc..
}
}
【问题讨论】:
标签: java unit-testing easymock