@@ -4,7 +4,6 @@ Camunda specific stages and scenarios for the BDD testing tool JGiven written in
4
4
5
5
[ ![ Development braches] ( https://github.com/holunda-io/camunda-bpm-jgiven/workflows/Development%20braches/badge.svg )] ( https://github.com/holunda-io/camunda-bpm-jgiven/workflows )
6
6
[ ![ Maven Central] ( https://maven-badges.herokuapp.com/maven-central/io.holunda.testing/camunda-bpm-jgiven/badge.svg )] ( https://maven-badges.herokuapp.com/maven-central/io.holunda.testing/camunda-bpm-jgiven )
7
- [ ![ codecov] ( https://codecov.io/gh/holunda-io/camunda-bpm-jgiven/branch/master/graph/badge.svg )] ( https://codecov.io/gh/holunda-io/camunda-bpm-jgiven )
8
7
9
8
[ ![ Project Stats] ( https://www.openhub.net/p/camunda-bpm-jgiven/widgets/project_thin_badge.gif )] ( https://www.openhub.net/p/camunda-bpm-jgiven )
10
9
@@ -14,85 +13,139 @@ Starting from 2012, we are preaching that processes are no units. Behavior-drive
14
13
underlying testing methodology of scenario-based testing is a way more adequate and convenient for writing
15
14
process (model) tests.
16
15
17
- Our first attempts addressed testing frameworks Cucumber and JBehave. For JBehave we were even able to release
18
- an official [ Camunda BPM extension] ( https://github.com/camunda/camunda-bpm-jbehave ) . It turned out that the main problem
19
- in using it, was error-prone writing of the test specifications in Gherkin and glue code in Java.
16
+ Our first attempts addressed testing frameworks Cucumber and JBehave. For JBehave we were able to release
17
+ an official [ Camunda BPM extension] ( https://github.com/camunda/camunda-bpm-jbehave ) , but it turned out that the main problem
18
+ in using it, was error-prone writing of the test specifications in Gherkin (text files) and glue code them with Java.
20
19
21
20
This is, where [ JGiven] ( http://jgiven.org/ ) comes on the scene, allowing to write both in Java or any other JVM language
22
- by providing a nice API and later generating reports which are human readable.
21
+ by providing a nice API and later generating reports which are human- readable.
23
22
24
23
## Usage
25
24
26
25
Add the following dependency to your Maven pom:
27
26
28
- <dependency>
29
- <groupId>io.holunda.testing</groupId>
30
- <artifactId>camunda-bpm-jgiven</artifactId>
31
- <version>0.0.7</version>
32
- <scope>test</scope>
33
- </dependency>
34
-
27
+ ``` xml
28
+ <dependency >
29
+ <groupId >io.holunda.testing</groupId >
30
+ <artifactId >camunda-bpm-jgiven</artifactId >
31
+ <version >0.2.0</version >
32
+ <scope >test</scope >
33
+ </dependency >
34
+ ```
35
35
## Features
36
36
37
37
JGiven supports separation of the glue code (application driver) into so-called [ stages] ( http://jgiven.org/userguide/#_stages_and_state_sharing ) .
38
38
Stages contain assert and action methods and may be subclassed. This library provides a base class
39
39
` ProcessStage ` for building your process testing stages. Here is how the test then looks like
40
40
(written in Kotlin):
41
41
42
+ ### JUnit4
43
+
44
+ ``` kotlin
45
+ @Deployment(resources = [ApprovalProcessBean .RESOURCE ])
46
+ open class ApprovalProcessTest : ScenarioTest <ApprovalProcessActionStage , ApprovalProcessActionStage , ApprovalProcessThenStage >() {
47
+
48
+ @get: Rule
49
+ val rule: ProcessEngineRule = StandaloneInMemoryTestConfiguration ().rule()
50
+
51
+ @ScenarioState
52
+ val camunda = rule.processEngine
53
+
42
54
@Test
43
- fun `should automatically approve`() {
44
-
45
- val approvalRequestId = UUID.randomUUID().toString()
46
-
47
- given()
48
- .process_is_deployed(ApprovalProcessBean.KEY)
49
- .and()
50
- .process_is_started_for_request(approvalRequestId)
51
- .and()
52
- .approval_strategy_can_be_applied(Expressions.ApprovalStrategy.AUTOMATIC)
53
- .and()
54
- .automatic_approval_returns(Expressions.ApprovalDecision.APPROVE)
55
-
56
- whenever()
57
- .process_continues()
58
-
59
- then()
60
- .process_is_finished()
61
- .and()
62
- .process_has_passed(Elements.SERVICE_AUTO_APPROVE, Elements.END_APPROVED)
63
-
55
+ internal fun `should automatically approve` () {
56
+
57
+ val approvalRequestId = UUID .randomUUID().toString()
58
+
59
+ GIVEN
60
+ .process_is_deployed(ApprovalProcessBean .KEY )
61
+ . AND
62
+ .process_is_started_for_request(approvalRequestId)
63
+ . AND
64
+ .approval_strategy_can_be_applied(Expressions .ApprovalStrategy .AUTOMATIC )
65
+ . AND
66
+ .automatic_approval_returns(Expressions .ApprovalDecision .APPROVE )
67
+
68
+ WHEN
69
+ .process_continues()
70
+
71
+ THEN
72
+ .process_is_finished()
73
+ . AND
74
+ .process_has_passed(Elements .SERVICE_AUTO_APPROVE , Elements .END_APPROVED )
75
+
64
76
}
77
+ }
78
+ ```
79
+
80
+ ### JUnit5
81
+
82
+ ``` kotlin
83
+ @ExtendWith(ProcessEngineExtension ::class )
84
+ @Deployment(resources = [ApprovalProcessBean .RESOURCE ])
85
+ internal class ApprovalProcessTest :
86
+ ScenarioTest <ApprovalProcessActionStage , ApprovalProcessActionStage , ApprovalProcessThenStage >() {
87
+
88
+ @RegisterExtension
89
+ val extension = TestProcessEngine .DEFAULT
90
+
91
+ @ScenarioState
92
+ val camunda = extension.processEngine
93
+
94
+ @Test
95
+ internal fun `should automatically approve` () {
96
+
97
+ val approvalRequestId = UUID .randomUUID().toString()
98
+
99
+ GIVEN
100
+ .process_is_deployed(ApprovalProcessBean .KEY )
101
+ .AND
102
+ .process_is_started_for_request(approvalRequestId)
103
+ .AND
104
+ .approval_strategy_can_be_applied(Expressions .ApprovalStrategy .AUTOMATIC )
105
+ .AND
106
+ .automatic_approval_returns(Expressions .ApprovalDecision .APPROVE )
107
+
108
+ WHEN
109
+ .process_continues()
110
+
111
+ THEN
112
+ .process_is_finished()
113
+ .AND
114
+ .process_has_passed(Elements .SERVICE_AUTO_APPROVE , Elements .END_APPROVED )
65
115
66
- And here is the corresponding stage:
67
-
68
- open class ApprovalProcessActionStage : ProcessStage<ApprovalProcessActionStage, ApprovalProcessBean>() {
69
-
70
- @BeforeStage
71
- open fun `automock all delegates`() {
72
- CamundaMockito.registerJavaDelegateMock(DETERMINE_APPROVAL_STRATEGY)
73
- CamundaMockito.registerJavaDelegateMock(AUTOMATICALLY_APPROVE_REQUEST)
74
- CamundaMockito.registerJavaDelegateMock(ApprovalProcessBean.Expressions.LOAD_APPROVAL_REQUEST)
75
- }
76
-
77
- open fun process_is_started_for_request(approvalRequestId: String): ApprovalProcessActionStage {
78
- processInstanceSupplier = ApprovalProcessBean(camunda.processEngine)
79
- processInstanceSupplier.start(approvalRequestId)
80
- assertThat(processInstanceSupplier.processInstance).isNotNull
81
- assertThat(processInstanceSupplier.processInstance).isStarted
82
- return self()
83
- }
84
-
85
- fun approval_strategy_can_be_applied(approvalStrategy: String): ApprovalProcessActionStage {
86
- getJavaDelegateMock(DETERMINE_APPROVAL_STRATEGY).onExecutionSetVariables(Variables.putValue(APPROVAL_STRATEGY, approvalStrategy))
87
- return self()
88
- }
89
-
90
- fun automatic_approval_returns(approvalDecision: String): ApprovalProcessActionStage {
91
- getJavaDelegateMock(AUTOMATICALLY_APPROVE_REQUEST).onExecutionSetVariables(Variables.putValue(APPROVAL_DECISION, approvalDecision))
92
- return self()
93
- }
94
116
}
95
-
117
+ }
118
+ ```
119
+
120
+ Here is the corresponding stage, providing the steps used in the test:
121
+
122
+ ``` kotlin
123
+ class ApprovalProcessActionStage : ProcessStage <ApprovalProcessActionStage , ApprovalProcessBean >() {
124
+
125
+ @BeforeStage
126
+ fun `automock all delegates` () {
127
+ CamundaMockito .registerJavaDelegateMock(DETERMINE_APPROVAL_STRATEGY )
128
+ CamundaMockito .registerJavaDelegateMock(AUTOMATICALLY_APPROVE_REQUEST )
129
+ CamundaMockito .registerJavaDelegateMock(ApprovalProcessBean .Expressions .LOAD_APPROVAL_REQUEST )
130
+ }
131
+
132
+ fun process_is_started_for_request (approvalRequestId : String ) = step {
133
+ processInstanceSupplier = ApprovalProcessBean (camunda.processEngine)
134
+ processInstanceSupplier.start(approvalRequestId)
135
+ assertThat(processInstanceSupplier.processInstance).isNotNull
136
+ assertThat(processInstanceSupplier.processInstance).isStarted
137
+ }
138
+
139
+ fun approval_strategy_can_be_applied (approvalStrategy : String ) = step {
140
+ getJavaDelegateMock(DETERMINE_APPROVAL_STRATEGY ).onExecutionSetVariables(Variables .putValue(APPROVAL_STRATEGY , approvalStrategy))
141
+ }
142
+
143
+ fun automatic_approval_returns (approvalDecision : String ) = step {
144
+ getJavaDelegateMock(AUTOMATICALLY_APPROVE_REQUEST ).onExecutionSetVariables(Variables .putValue(APPROVAL_DECISION , approvalDecision))
145
+ }
146
+ }
147
+ ```
148
+
96
149
The resulting report:
97
150
98
151
![ JGiven Process Report] ( docs/report.png )
@@ -115,12 +168,8 @@ If you have permissions to release, make sure all branches are fetched and run:
115
168
./mvnw gitflow:release-start
116
169
./mvnw gitflow:release-finish
117
170
118
- from cli. This will update the poms of ` develop ` and ` master ` branches.
119
- If you want to publish to central and have sufficient permissions, run
120
-
121
- ./mvnw clean deploy -Prelease -DskipExamples
122
-
123
- on ` master ` branch. Don't forget to close and release repository on https://oss.sonatype.org/#stagingRepositories .
171
+ from cli. This will update the poms of ` develop ` and ` master ` branches
172
+ and start GitHub actions producing a new release.
124
173
125
174
126
175
### Current maintainers
@@ -130,5 +179,3 @@ on `master` branch. Don't forget to close and release repository on https://oss.
130
179
* [ Jan Galinski] ( https://github.com/jangalinski )
131
180
* [ Andre Hegerath] ( https://github.com/a-hegerath )
132
181
* [ Stefan Zilske] ( https://github.com/stefanzilske )
133
-
134
-
0 commit comments