我有两个豆子:
@Component
public class StudentServices {
// ... member variables, etc.
@Lookup
public SchoolNotification getNotification() {
return null;
}
// ... getters and setters
}
第二个bean:
@Component
@Scope("prototype")
public class SchoolNotification {
// ... prototype-scoped state
}
我需要帮助为StudentService编写单元测试,以某种方式模拟SchoolNotification。
Mockito.mock不起作用,因为两个bean具有不同的作用域,并且每次执行StudentServices.getNotification()时,spring上下文都会提供SchoolNotification的新实例。
任何帮助将不胜感激!
答案 0 :(得分:0)
要回答我自己的问题,已使用间谍程序对此进行了修复。