版权声明:本文为博主原创文章,未经博主允许不得转载。不经过允许copy,讲追究法律责任,欢迎加入我们的学习提升群523988350,可以相互交流 https://blog.csdn.net/qq_30739519/article/details/89598608
Writing Tests
您可以使用zeebe-test
模块为您的工作人员和BPMN工作流编写JUnit测试。它提供了一个JUnit规则来引导代理和一些基本断言。
Usage in a Maven project
Add zeebe-test
as Maven test dependency to your project:
<dependency>
<groupId>io.zeebe</groupId>
<artifactId>zeebe-test</artifactId>
<scope>test</scope>
</dependency>
Bootstrap the Broker
在测试用例中使用ZeebeTestRule
来启动嵌入式broker。它包含一个客户端,可用于部署BPMN工作流或创建实例。
import io.zeebe.client.ZeebeClient;
import io.zeebe.client.api.events.WorkflowInstanceEvent;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
public class MyTest {
@Rule public final ZeebeTestRule testRule = new ZeebeTestRule();
private ZeebeClient client;
@Test
public void test() {
client = testRule.getClient();
client
.newDeployCommand()
.addResourceFromClasspath("process.bpmn")
.send()
.join();
final WorkflowInstanceEvent workflowInstance =
client
.newCreateInstanceCommand()
.bpmnProcessId("process")
.latestVersion()
.send()
.join();
}
}
Verify the Result
ZeebeTestRule
还提供了一些AssertJ风格的基本断言。断言的入口点是zeebestrule.assertthat(…)。
final WorkflowInstanceEvent workflowInstance = ...
ZeebeTestRule.assertThat(workflowInstance)
.isEnded()
.hasPassed("start", "task", "end")
.hasVariables("result", 21.0);
zeebe qq交流群群号:856546010