0
我搜索瞭解決方案,但無濟於事。Jmockit:嘲笑@EJB
public class Bean {
@EJB
private Session session;
public String register(String a, String b, String c) {
return session.create(a, b, c).toString();
}
和我有一個測試類
@Test
public void testRegister(String a, String b, String c) {
new MockUp<Bean>() {
@Mocked Session session;
};
System.out.println("session: "+ session);
Bean bean = new Bean();
System.out.println("apiService: "+ bean);
System.out.println("bean.register: "+ bean.register("a", "b", "c"));
}
我試着幾種不同的方式爲instanitating /注入EJB。但它全部返回null。你如何注入@EJB會話來測試註冊方法?