【发布时间】:2014-03-17 10:47:08
【问题描述】:
我正在尝试编写一些基本的 backingBean 测试,但我一直在模拟 UserContext 和 facesContext。
此代码在我要测试的代码中:
UserContext uc = ContextProvider.getContext();
Locale locale = uc.getLocale();
ResourceBundle bundle = ResourceBundle.getBundle("AppMessages", locale);
String message = bundle.getString("this.is.the.message.key");
在另一个代码块中,我得到了以下内容:
FacesContext fc = FacesContext.getCurrentInstance();
fc.getExternalContext().redirect(handleRedirect("someString"));
如何在标准的 jUnit 测试中仅使用 mockito 来模拟这些?还是我必须使用 PowerMock 之类的东西?
【问题讨论】:
标签: unit-testing jsf jsf-2 junit mockito