我有一个父工作流(ParentWorkflow)调用一个子工作流(ChildWorkflow),我正在尝试测试这个调用。
父代码如下所示:
public class ParentWorkflow {
private final ChildWorkflowClientFactory childWorkflowClientFactory =
new ChildWorkflowClientFactoryImpl();
public void runWorkflow() {
new TryCatch() {
@Override
protected void doTry() throws Throwable {
Promise<Void> workflowFinished = childWorkflowClient.childWorkflow(x);
...
}
...
}
}
我想模拟
childWorkflowClient.childWorkflow(x)
调用,但是当我连接单元测试时,我似乎没有注入客户端工厂的选项,单元测试代码如下所示:
@Rule
public WorkflowTest workflowTest = new WorkflowTest();
@Mock
private Activities mockActivities;
private ParentWorkflowClientFactory workflowFactory
= new ParentWorkflowClientFactoryImpl();
@Before
public void setUp() throws Exception {
// set up mocks
initMocks(this);
workflowTest.addActivitiesImplementation(mockActivities);
workflowTest.addWorkflowImplementationType(ParentWorkflowImpl.class);
workflowTest.addWorkflowImplementationType(ChildWorkflowImpl.class);
我似乎无法将任何东西传递给工作流实现类,还有其他方法可以模拟子工作流吗?