-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: added camunda-process-test-coverage examples
- Loading branch information
Showing
20 changed files
with
1,148 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.example.it</groupId> | ||
<artifactId>bpmndt-coverage-junit5</artifactId> | ||
<version>1</version> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
|
||
<!-- Versions --> | ||
<assertj.version>3.24.2</assertj.version> | ||
<camunda.bpm.version>7.19.0</camunda.bpm.version> | ||
<camunda.bpm.assert.version>15.0.0</camunda.bpm.assert.version> | ||
<camunda.process.test.coverage.version>2.3.0</camunda.process.test.coverage.version> | ||
<h2.version>2.2.220</h2.version> | ||
<junit.jupiter.version>5.9.3</junit.jupiter.version> | ||
<slf4j.version>1.7.36</slf4j.version> | ||
|
||
<plugin.version>0.9.0-SNAPSHOT</plugin.version> | ||
</properties> | ||
|
||
<repositories> | ||
<repository> | ||
<id>camunda-bpm-nexus</id> | ||
<name>camunda-bpm-nexus</name> | ||
<url>https://artifacts.camunda.com/artifactory/public/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.camunda.bpm</groupId> | ||
<artifactId>camunda-bom</artifactId> | ||
<version>${camunda.bpm.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.camunda.bpm</groupId> | ||
<artifactId>camunda-engine</artifactId> | ||
</dependency> | ||
|
||
<!-- Test --> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-log4j12</artifactId> | ||
<version>${slf4j.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<version>${junit.jupiter.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.h2database</groupId> | ||
<artifactId>h2</artifactId> | ||
<version>${h2.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.camunda.bpm.assert</groupId> | ||
<artifactId>camunda-bpm-assert</artifactId> | ||
<version>${camunda.bpm.assert.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<version>${assertj.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.camunda.community.process_test_coverage</groupId> | ||
<artifactId>camunda-process-test-coverage-junit5-platform-7</artifactId> | ||
<version>${camunda.process.test.coverage.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- needed for camunda-process-test-coverage-junit5-platform-7 --> | ||
<dependency> | ||
<groupId>org.camunda.bpm</groupId> | ||
<artifactId>camunda-bpm-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.1</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.camunda.community</groupId> | ||
<artifactId>bpmn-driven-testing-maven-plugin</artifactId> | ||
<version>${plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>generator</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<jUnit5Enabled>true</jUnit5Enabled> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
142 changes: 142 additions & 0 deletions
142
integration-tests/coverage-junit5/src/main/resources/example.bpmn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:bpmndt="http://camunda.org/schema/extension/bpmn-driven-testing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_07m9v4h" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.4.0"> | ||
<bpmn:process id="example" isExecutable="true"> | ||
<bpmn:extensionElements> | ||
<bpmndt:testCases> | ||
<bpmndt:testCase> | ||
<bpmndt:name>A</bpmndt:name> | ||
<bpmndt:path> | ||
<bpmndt:node>startEvent</bpmndt:node> | ||
<bpmndt:node>fork</bpmndt:node> | ||
<bpmndt:node>eventA</bpmndt:node> | ||
<bpmndt:node>join</bpmndt:node> | ||
<bpmndt:node>endEvent</bpmndt:node> | ||
</bpmndt:path> | ||
</bpmndt:testCase> | ||
<bpmndt:testCase> | ||
<bpmndt:name>B</bpmndt:name> | ||
<bpmndt:path> | ||
<bpmndt:node>startEvent</bpmndt:node> | ||
<bpmndt:node>fork</bpmndt:node> | ||
<bpmndt:node>eventB</bpmndt:node> | ||
<bpmndt:node>join</bpmndt:node> | ||
<bpmndt:node>endEvent</bpmndt:node> | ||
</bpmndt:path> | ||
</bpmndt:testCase> | ||
<bpmndt:testCase> | ||
<bpmndt:name>C</bpmndt:name> | ||
<bpmndt:path> | ||
<bpmndt:node>startEvent</bpmndt:node> | ||
<bpmndt:node>fork</bpmndt:node> | ||
<bpmndt:node>eventC</bpmndt:node> | ||
<bpmndt:node>join</bpmndt:node> | ||
<bpmndt:node>endEvent</bpmndt:node> | ||
</bpmndt:path> | ||
</bpmndt:testCase> | ||
</bpmndt:testCases> | ||
</bpmn:extensionElements> | ||
<bpmn:startEvent id="startEvent"> | ||
<bpmn:outgoing>Flow_050eadf</bpmn:outgoing> | ||
</bpmn:startEvent> | ||
<bpmn:exclusiveGateway id="fork" default="Flow_04buioh"> | ||
<bpmn:incoming>Flow_050eadf</bpmn:incoming> | ||
<bpmn:outgoing>Flow_04buioh</bpmn:outgoing> | ||
<bpmn:outgoing>Flow_0kju9wf</bpmn:outgoing> | ||
<bpmn:outgoing>Flow_187cunb</bpmn:outgoing> | ||
</bpmn:exclusiveGateway> | ||
<bpmn:sequenceFlow id="Flow_050eadf" sourceRef="startEvent" targetRef="fork" /> | ||
<bpmn:intermediateThrowEvent id="eventA"> | ||
<bpmn:incoming>Flow_04buioh</bpmn:incoming> | ||
<bpmn:outgoing>Flow_0adbv0z</bpmn:outgoing> | ||
</bpmn:intermediateThrowEvent> | ||
<bpmn:sequenceFlow id="Flow_04buioh" sourceRef="fork" targetRef="eventA" /> | ||
<bpmn:exclusiveGateway id="join"> | ||
<bpmn:incoming>Flow_0adbv0z</bpmn:incoming> | ||
<bpmn:incoming>Flow_1cg8y7u</bpmn:incoming> | ||
<bpmn:incoming>Flow_1cw2vtv</bpmn:incoming> | ||
<bpmn:outgoing>Flow_1a9zsda</bpmn:outgoing> | ||
</bpmn:exclusiveGateway> | ||
<bpmn:sequenceFlow id="Flow_0adbv0z" sourceRef="eventA" targetRef="join" /> | ||
<bpmn:intermediateThrowEvent id="eventB"> | ||
<bpmn:incoming>Flow_0kju9wf</bpmn:incoming> | ||
<bpmn:outgoing>Flow_1cg8y7u</bpmn:outgoing> | ||
</bpmn:intermediateThrowEvent> | ||
<bpmn:sequenceFlow id="Flow_0kju9wf" sourceRef="fork" targetRef="eventB"> | ||
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${branch == 'b'}</bpmn:conditionExpression> | ||
</bpmn:sequenceFlow> | ||
<bpmn:sequenceFlow id="Flow_1cg8y7u" sourceRef="eventB" targetRef="join" /> | ||
<bpmn:endEvent id="endEvent"> | ||
<bpmn:incoming>Flow_1a9zsda</bpmn:incoming> | ||
</bpmn:endEvent> | ||
<bpmn:sequenceFlow id="Flow_1a9zsda" sourceRef="join" targetRef="endEvent" /> | ||
<bpmn:intermediateThrowEvent id="eventC"> | ||
<bpmn:incoming>Flow_187cunb</bpmn:incoming> | ||
<bpmn:outgoing>Flow_1cw2vtv</bpmn:outgoing> | ||
</bpmn:intermediateThrowEvent> | ||
<bpmn:sequenceFlow id="Flow_187cunb" sourceRef="fork" targetRef="eventC"> | ||
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${branch == 'c'}</bpmn:conditionExpression> | ||
</bpmn:sequenceFlow> | ||
<bpmn:sequenceFlow id="Flow_1cw2vtv" sourceRef="eventC" targetRef="join" /> | ||
</bpmn:process> | ||
<bpmndi:BPMNDiagram id="BPMNDiagram_1"> | ||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="example"> | ||
<bpmndi:BPMNEdge id="Flow_050eadf_di" bpmnElement="Flow_050eadf"> | ||
<di:waypoint x="215" y="107" /> | ||
<di:waypoint x="265" y="107" /> | ||
</bpmndi:BPMNEdge> | ||
<bpmndi:BPMNEdge id="Flow_04buioh_di" bpmnElement="Flow_04buioh"> | ||
<di:waypoint x="315" y="107" /> | ||
<di:waypoint x="372" y="107" /> | ||
</bpmndi:BPMNEdge> | ||
<bpmndi:BPMNEdge id="Flow_0adbv0z_di" bpmnElement="Flow_0adbv0z"> | ||
<di:waypoint x="408" y="107" /> | ||
<di:waypoint x="465" y="107" /> | ||
</bpmndi:BPMNEdge> | ||
<bpmndi:BPMNEdge id="Flow_0kju9wf_di" bpmnElement="Flow_0kju9wf"> | ||
<di:waypoint x="290" y="132" /> | ||
<di:waypoint x="290" y="220" /> | ||
<di:waypoint x="372" y="220" /> | ||
</bpmndi:BPMNEdge> | ||
<bpmndi:BPMNEdge id="Flow_1cg8y7u_di" bpmnElement="Flow_1cg8y7u"> | ||
<di:waypoint x="408" y="220" /> | ||
<di:waypoint x="490" y="220" /> | ||
<di:waypoint x="490" y="132" /> | ||
</bpmndi:BPMNEdge> | ||
<bpmndi:BPMNEdge id="Flow_1a9zsda_di" bpmnElement="Flow_1a9zsda"> | ||
<di:waypoint x="515" y="107" /> | ||
<di:waypoint x="572" y="107" /> | ||
</bpmndi:BPMNEdge> | ||
<bpmndi:BPMNEdge id="Flow_187cunb_di" bpmnElement="Flow_187cunb"> | ||
<di:waypoint x="290" y="132" /> | ||
<di:waypoint x="290" y="330" /> | ||
<di:waypoint x="372" y="330" /> | ||
</bpmndi:BPMNEdge> | ||
<bpmndi:BPMNEdge id="Flow_1cw2vtv_di" bpmnElement="Flow_1cw2vtv"> | ||
<di:waypoint x="408" y="330" /> | ||
<di:waypoint x="490" y="330" /> | ||
<di:waypoint x="490" y="132" /> | ||
</bpmndi:BPMNEdge> | ||
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="startEvent"> | ||
<dc:Bounds x="179" y="89" width="36" height="36" /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Gateway_0mlop5m_di" bpmnElement="fork" isMarkerVisible="true"> | ||
<dc:Bounds x="265" y="82" width="50" height="50" /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Event_1wv8tps_di" bpmnElement="eventA"> | ||
<dc:Bounds x="372" y="89" width="36" height="36" /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Gateway_1m92o14_di" bpmnElement="join" isMarkerVisible="true"> | ||
<dc:Bounds x="465" y="82" width="50" height="50" /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Event_16z0ytr_di" bpmnElement="eventB"> | ||
<dc:Bounds x="372" y="202" width="36" height="36" /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Event_1y3pj3f_di" bpmnElement="endEvent"> | ||
<dc:Bounds x="572" y="89" width="36" height="36" /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Event_1u1mkzw_di" bpmnElement="eventC"> | ||
<dc:Bounds x="372" y="312" width="36" height="36" /> | ||
</bpmndi:BPMNShape> | ||
</bpmndi:BPMNPlane> | ||
</bpmndi:BPMNDiagram> | ||
</bpmn:definitions> |
32 changes: 32 additions & 0 deletions
32
integration-tests/coverage-junit5/src/test/java/org/example/it/CoverageBranchABTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.example.it; | ||
|
||
import org.camunda.bpm.engine.test.Deployment; | ||
import org.camunda.bpm.engine.test.assertions.bpmn.ProcessInstanceAssert; | ||
import org.camunda.community.process_test_coverage.junit5.platform7.ProcessEngineCoverageExtension; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import generated.example.TC_A; | ||
import generated.example.TC_B; | ||
|
||
@Deployment(resources = "example.bpmn") // needed for some reason | ||
public class CoverageBranchABTest { | ||
|
||
@RegisterExtension | ||
public static ProcessEngineCoverageExtension coverage = CoverageExtensionProvider.get(); // must be static | ||
|
||
@RegisterExtension | ||
public TC_A tcA = new TC_A(); | ||
@RegisterExtension | ||
public TC_B tcB = new TC_B(); | ||
|
||
@Test | ||
public void testA() { | ||
tcA.createExecutor().withVariable("branch", "a").verify(ProcessInstanceAssert::isEnded).execute(); | ||
} | ||
|
||
@Test | ||
public void testB() { | ||
tcB.createExecutor().withVariable("branch", "b").verify(ProcessInstanceAssert::isEnded).execute(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
integration-tests/coverage-junit5/src/test/java/org/example/it/CoverageBranchCTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.example.it; | ||
|
||
import org.camunda.bpm.engine.test.Deployment; | ||
import org.camunda.bpm.engine.test.assertions.bpmn.ProcessInstanceAssert; | ||
import org.camunda.community.process_test_coverage.junit5.platform7.ProcessEngineCoverageExtension; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import generated.example.TC_C; | ||
|
||
@Deployment(resources = "example.bpmn") // needed for some reason | ||
public class CoverageBranchCTest { | ||
|
||
@RegisterExtension | ||
public static ProcessEngineCoverageExtension coverage = CoverageExtensionProvider.get(); // must be static | ||
|
||
@RegisterExtension | ||
public TC_C tcC = new TC_C(); | ||
|
||
@Test | ||
public void testC() { | ||
tcC.createExecutor().withVariable("branch", "c").verify(ProcessInstanceAssert::isEnded).execute(); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...gration-tests/coverage-junit5/src/test/java/org/example/it/CoverageExtensionProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.example.it; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; | ||
import org.camunda.bpm.engine.impl.cfg.ProcessEnginePlugin; | ||
import org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration; | ||
import org.camunda.community.bpmndt.api.cfg.BpmndtProcessEnginePlugin; | ||
import org.camunda.community.process_test_coverage.engine.platform7.ProcessCoverageConfigurator; | ||
import org.camunda.community.process_test_coverage.junit5.platform7.ProcessEngineCoverageExtension; | ||
|
||
public class CoverageExtensionProvider { | ||
|
||
private static final ProcessEngineCoverageExtension extension; | ||
|
||
static { | ||
// configure engine for running generated test cases | ||
List<ProcessEnginePlugin> processEnginePlugins = new LinkedList<>(); | ||
processEnginePlugins.add(new BpmndtProcessEnginePlugin()); | ||
|
||
ProcessEngineConfigurationImpl processEngineConfiguration = new StandaloneInMemProcessEngineConfiguration(); | ||
processEngineConfiguration.setProcessEnginePlugins(processEnginePlugins); | ||
|
||
// configure engine for collecting process test coverage | ||
ProcessCoverageConfigurator.initializeProcessCoverageExtensions(processEngineConfiguration); | ||
|
||
extension = ProcessEngineCoverageExtension.builder(processEngineConfiguration) | ||
.assertClassCoverageAtLeast(0.75) | ||
.build(); | ||
} | ||
|
||
/** | ||
* Provides a cached instance of the JUnit5 coverage extension, so that the same process engine is | ||
* used for all tests. | ||
* | ||
* @return The cached coverage extension. | ||
*/ | ||
public static ProcessEngineCoverageExtension get() { | ||
return extension; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
integration-tests/coverage-junit5/src/test/resources/log4j.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
log4j.rootLogger=INFO, stdout | ||
|
||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender | ||
log4j.appender.stdout.Target=System.out | ||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n | ||
|
||
log4j.logger.org.camunda=INFO | ||
log4j.logger.org.springframework=WARN |
Oops, something went wrong.