我正在使用UnitilsJUnit4和EasyMock在我的代碼中測試郵件功能。使用EasyMock進行單元測試時發生意外的方法調用
我的代碼是這樣的..
public void prepare(MimeMessage mimeMessage) {
// some code ..
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, true);
// some mail settings ..
}
當我測試的方法prepare
,這是給下面的異常..但它在下面顯示的方法是從Spring框架類。
java.lang.AssertionError:
Unexpected method call setContent([email protected]):
setContent([email protected]): expected: 1, actual: 0
at $javax.mail.internet.MimeMessage$$EnhancerByCGLIB$$614de43f.setContent(<generated>)
at org.springframework.mail.javamail.MimeMessageHelper.createMimeMultiparts(MimeMessageHelper.java:344)
at org.springframework.mail.javamail.MimeMessageHelper.<init>(MimeMessageHelper.java:290)
at org.springframework.mail.javamail.MimeMessageHelper.<init>(MimeMessageHelper.java:247)
at org.springframework.mail.javamail.MimeMessageHelper.<init>(MimeMessageHelper.java:226)
請幫我解決上面的問題..如何測試我的方法?