Spring 在单元测试期间注入drools StatefulKnowledgeSession实例
我正在开发一个spring应用程序,它有一个如上所示的表单类 测试类的形式如下所示Spring 在单元测试期间注入drools StatefulKnowledgeSession实例,spring,mockito,drools,Spring,Mockito,Drools,我正在开发一个spring应用程序,它有一个如上所示的表单类 测试类的形式如下所示 public class App { @Autowired private KnowledgeBase kBase; private StatefulKnowledgeSession statefulKnowledgeSession; public void method() { statefulKnowledgeSession = kBase.newStat
public class App {
@Autowired
private KnowledgeBase kBase;
private StatefulKnowledgeSession statefulKnowledgeSession;
public void method() {
statefulKnowledgeSession = kBase.newStatefulKnowledgeSession();
statefulKnowledgeSession.fireAllRules();
}
}
上面显示的测试类不包含完整的代码,但它只是告诉类的外观。现在我想通过调用实际方法在单元测试期间触发规则,但我不能使用@Spy,因为StatefulKnowledgeSession是一个接口@Spy需要创建一个对象,但我显然无法实例化接口
请帮忙 你难道看不到在我们的测试中你得到了什么具体的
StatefulKnowledgeSession
实现吗?我调试了代码来检查类名,但唯一显示的是StatefulKnowledgeSessionImpl,它意味着StatefulKnowledgeSession的实现。好吧,那是你的具体类
public class AppTest {
@Spy
private StatefulKnowledgeSession statefulKnowledgeSession;
}