You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docusaurus/docs/bpmn/ch04-API.md
+8-57Lines changed: 8 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -342,13 +342,13 @@ Additionally, it’s possible to register custom functions that can be used in e
342
342
343
343
Business processes are an integral part of software projects and they should be tested in the same way normal application logic is tested: with unit tests. Since Flowable is an embeddable Java engine, writing unit tests for business processes is as simple as writing regular unit tests.
344
344
345
-
Flowable supports JUnit versions 3, 4 and 5 styles of unit testing.
345
+
Flowable supports JUnit Jupiter styles of unit testing.
346
346
347
-
In the JUnit 5 style one needs to use the org.flowable.engine.test.FlowableTest annotation or register the org.flowable.engine.test.FlowableExtension manually.
348
-
The FlowableTest annotation is just a metaannotation and the does the registration of the FlowableExtension (i.e. it does @ExtendWith(FlowableExtension.class)).
347
+
In the JUnit Jupiter style one needs to use the org.flowable.engine.test.FlowableTest annotation or register the org.flowable.engine.test.FlowableExtension manually.
348
+
The FlowableTest annotation is just a meta-annotation and does the registration of the FlowableExtension (i.e., it does @ExtendWith(FlowableExtension.class)).
349
349
This will make the ProcessEngine and the services available as parameters into the test and lifecycle methods (@BeforeAll, @BeforeEach, @AfterEach, @AfterAll).
350
350
Before each test the processEngine will be initialized by default with the flowable.cfg.xml resource on the classpath.
351
-
In order to specify a different configuration file the org.flowable.engine.test.ConfigurationResource annotation needs to be used (see second example).
351
+
To specify a different configuration file, the org.flowable.engine.test.ConfigurationResource annotation needs to be used (see second example).
352
352
Process engines are cached statically over multiple unit tests when the configuration resource is the same.
353
353
354
354
By using FlowableExtension, you can annotate test methods with org.flowable.engine.test.Deployment.
@@ -357,9 +357,9 @@ In case there are no resources defined, a resource file of the form testClassNam
357
357
At the end of the test, the deployment will be deleted, including all related process instances, tasks, and so on.
358
358
See the Deployment class for more information.
359
359
360
-
Taking all that in account, a JUnit 5 test looks as follows:
360
+
Taking all that into account, a JUnit Jupiter test looks as follows:
361
361
362
-
**JUnit 5 test with default resource.**
362
+
**JUnit Jupiter test with default resource.**
363
363
364
364
@FlowableTest
365
365
class MyBusinessProcessTest {
@@ -388,9 +388,9 @@ Taking all that in account, a JUnit 5 test looks as follows:
388
388
}
389
389
}
390
390
391
-
With JUnit 5 you can also inject the id of the deployment (with +org.flowable.engine.test.DeploymentId+_) into your test and lifecycle methods.
391
+
With JUnit Jupiter you can also inject the id of the deployment (with +org.flowable.engine.test.DeploymentId+_) into your test and lifecycle methods.
392
392
393
-
**JUnit 5 test with a custom resource file.**
393
+
**JUnit Jupiter test with a custom resource file.**
394
394
395
395
@FlowableTest
396
396
@ConfigurationResource("flowable.custom.cfg.xml")
@@ -420,55 +420,6 @@ Taking all that in account, a JUnit 5 test looks as follows:
420
420
}
421
421
}
422
422
423
-
In the JUnit 3 style, the org.flowable.engine.test.FlowableTestCase must be extended. This will make the ProcessEngine and the services available through protected member fields. In the setup() of the test, the processEngine will be initialized by default with the flowable.cfg.xml resource on the classpath. To specify a different configuration file, override the *getConfigurationResource()* method. Process engines are cached statically over multiple unit tests when the configuration resource is the same.
424
-
425
-
As with the FlowableExtension (see above), extending the FlowableTestCase will enable the use of the org.flowable.engine.test.Deployment annotation (see above for an explanation of its use and configuration). Before the test is run, a resource file of the form testClassName.testMethod.bpmn20.xml in the same package as the test class, will be deployed. At the end of the test, the deployment will be deleted, including all related process instances, tasks, and so on. The Deployment annotation also supports setting the resource location explicitly. See the class itself for more information.
426
-
427
-
Taking all that in account, a JUnit 3 style test looks as follows.
428
-
429
-
**JUnit 3 test with default resource file.**
430
-
431
-
public class MyBusinessProcessTest extends FlowableTestCase {
To get the same functionality when using the JUnit 4 style of writing unit tests, the org.flowable.engine.test.FlowableRule Rule must be used. Through this rule, the process engine and services are available through getters.
446
-
As with the FlowableExtension (see above), including this Rule will enable the use of the org.flowable.engine.test.Deployment annotation (see above for an explanation of its use and configuration) and it will look for the default configuration file on the classpath. Process engines are statically cached over multiple unit tests when using the same configuration resource.
447
-
448
-
The following code snippet shows an example of using the JUnit 4 style of testing and the usage of the FlowableRule.
449
-
450
-
**JUnit 4 test with default resource file.**
451
-
452
-
public class MyBusinessProcessTest {
453
-
454
-
@Rule
455
-
public FlowableRule flowableRule = new FlowableRule();
When using the in-memory H2 database for unit tests, the following instructions allow you to easily inspect the data in the Flowable database during a debugging session. The screenshots here are taken in Eclipse, but the mechanism should be similar for other IDEs.
Copy file name to clipboardExpand all lines: docs/docusaurus/docs/bpmn/ch05-Spring.md
+2-38Lines changed: 2 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -218,13 +218,12 @@ In addition to using the values listed above for deploymentMode, you may require
218
218
## Unit testing
219
219
220
220
When integrating with Spring, business processes can be tested very easily using the standard [Flowable testing facilities](bpmn/ch04-API.md#unit-testing).
221
-
The following examples show how a business process is tested in typical Spring-based JUnit 4 and 5 test:
221
+
The following examples show how a business process is tested in typical Spring-based JUnit Jupiter test:
Note that for this to work, you need to define an *org.flowable.engine.test.Flowable* bean in the Spring configuration (which is injected by auto-wiring in the example above).
When using Hibernate 4.2.x JPA in service task or listener logic in the Flowable engine, an additional dependency to Spring ORM is needed. This is not needed for Hibernate 4.1.x or earlier. The following dependency should be added:
Copy file name to clipboardExpand all lines: docs/docusaurus/docs/cmmn/ch03-API.md
+7-44Lines changed: 7 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -386,10 +386,10 @@ Delete all HistoricCaseInstances and their related data that are older than one
386
386
Cases are an integral part of software projects and they should be tested in the same way normal application logic is tested: with unit tests.
387
387
Since Flowable is an embeddable Java engine, writing unit tests for business cases is as simple as writing regular unit tests.
388
388
389
-
Flowable supports JUnit versions 4 and 5 styles of unit testing.
389
+
Flowable supports JUnit Jupiter styles of unit testing.
390
390
391
-
In the JUnit 5 style one needs to use the org.flowable.cmmn.engine.test.FlowableCmmnTest annotation or register the org.flowable.cmmn.engine.test.FlowableCmmnExtension manually.
392
-
The FlowableCmmnTest annotation is just a metaannotation and the does the registration of the FlowableCmmnExtension (i.e. it does @ExtendWith(FlowableCmmnExtension.class)).
391
+
In the JUnit Jupiter style one needs to use the org.flowable.cmmn.engine.test.FlowableCmmnTest annotation or register the org.flowable.cmmn.engine.test.FlowableCmmnExtension manually.
392
+
The FlowableCmmnTest annotation is just a meta-annotation and does the registration of the FlowableCmmnExtension (i.e. it does @ExtendWith(FlowableCmmnExtension.class)).
393
393
This will make the CmmnEngine and the services available as parameters into the test and lifecycle methods (@BeforeAll, @BeforeEach, @AfterEach, @AfterAll).
394
394
Before each test the cmmnEngine will be initialized by default with the flowable.cmmn.cfg.xml resource on the classpath.
395
395
In order to specify a different configuration file the org.flowable.cmmn.engine.test.CmmnConfigurationResource annotation needs to be used (see the second example).
@@ -401,9 +401,9 @@ In case there are no resources defined, a resource file of the form testClassNam
401
401
At the end of the test, the deployment will be deleted, including all related case instances, tasks, and so on.
402
402
See the CmmnDeployment class for more information.
403
403
404
-
Taking all that into account, a JUnit 5 test looks as follows:
404
+
Taking all that into account, a JUnit Jupiter test looks as follows:
405
405
406
-
**Junit 5 test with the default resource.**
406
+
**Junit Jupiter test with the default resource.**
407
407
408
408
@FlowableCmmnTest
409
409
class MyTest {
@@ -436,9 +436,9 @@ Taking all that into account, a JUnit 5 test looks as follows:
436
436
}
437
437
}
438
438
439
-
With JUnit 5 you can also inject the id of the deployment (with +org.flowable.cmmn.engine.test.CmmnDeploymentId+_) into your test and lifecycle methods.
439
+
With JUnit Jupiter you can also inject the id of the deployment (with +org.flowable.cmmn.engine.test.CmmnDeploymentId+_) into your test and lifecycle methods.
In the JUnit 4 style, the *org.flowable.cmmn.engine.test.FlowableCmmnTestCase* is available as parent class. It uses a configuration file *flowable.cmmn.cfg.xml* by default or uses a standard CmmnEngine using an H2 in-memory database if such file is missing.
475
-
Behind the scenes, a CmmnTestRunner is used to initialise the CMMN engine. Note in the example below how the *@CmmnDeployment* annotation is used to automatically deploy the case definition (it will look for a .cmmn file in the same folder as the test class and expects the file to be named <Test class name>.<test method name>.cmmn.
476
-
477
-
public class MyTest extends FlowableCmmnTestCase {
Copy file name to clipboardExpand all lines: docs/docusaurus/docs/cmmn/ch04-Spring.md
+3-23Lines changed: 3 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -173,13 +173,12 @@ In addition to using the values listed above for deploymentMode, you may require
173
173
## Unit testing
174
174
175
175
When integrating with Spring, business cases can be tested very easily using the standard standard [Flowable testing facilities](cmmn/ch03-API.md#unit-testing).
176
-
The following examples show how a case definition is tested in typical Spring-based JUnit 4 and 5 test:
176
+
The following examples show how a case definition is tested in typical Spring-based JUnit Jupiter test:
Copy file name to clipboardExpand all lines: docs/docusaurus/docs/dmn/ch03-API.md
+8-36Lines changed: 8 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,16 +86,16 @@ Sometimes you need more powerful queries, for example, queries using an OR opera
86
86
87
87
As Flowable DMN is an embeddable Java engine, writing unit tests for DMN definitions is as simple as writing regular unit tests.
88
88
89
-
Flowable supports the JUnit version 4 and 5 style of unit testing.
89
+
Flowable supports the JUnit Jupiter style of unit testing.
90
90
91
-
In the JUnit 5 style one needs to use the org.flowable.dmn.engine.test.FlowableDmnTest annotation
91
+
In the JUnit Jupiter style one needs to use the org.flowable.dmn.engine.test.FlowableDmnTest annotation
92
92
or register the org.flowable.dmn.engine.test.FlowableDmnExtension manually.
93
-
The FlowableDmnTest annotation is just a metaannotation and the does the registration of the FlowableDmnExtension
93
+
The FlowableDmnTest annotation is just a meta-annotation and does the registration of the FlowableDmnExtension
94
94
(i.e. it does @ExtendWith(FlowableDmnExtension.class)).
95
95
This will make the DmnEngine and the services available as parameters into the test and lifecycle methods
96
96
(@BeforeAll, @BeforeEach, @AfterEach, @AfterAll).
97
97
Before each test the dmnEngine will be initialized by default with the flowable.dmn.cfg.xml resource on the classpath.
98
-
In order to specify a different configuration file the org.flowable.dmn.engine.test.DmnConfigurationResource
98
+
To specify a different configuration file the org.flowable.dmn.engine.test.DmnConfigurationResource
99
99
annotation needs to be used (see second example).
100
100
Dmn engines are cached statically over multiple unit tests when the configuration resource is the same.
101
101
@@ -110,9 +110,9 @@ in the same package as the test class, will be deployed.
110
110
At the end of the test, the deployment will be deleted, including all related dmn definitions, executions, and so on.
111
111
See the DmnDeployment class for more information.
112
112
113
-
Taking all that in account, a JUnit 5 test looks as follows:
113
+
Taking all that into account, a JUnit Jupiter test looks as follows:
114
114
115
-
**JUnit 5 test with default resource.**
115
+
**JUnit Jupiter test with default resource.**
116
116
117
117
@FlowableDmnTest
118
118
class MyDecisionTableTest {
@@ -132,9 +132,9 @@ Taking all that in account, a JUnit 5 test looks as follows:
132
132
}
133
133
}
134
134
135
-
With JUnit 5 you can also inject the id of the deployment (with +org.flowable.dmn.engine.test.DmnDeploymentId+_) into your test and lifecycle methods.
135
+
With JUnit Jupiter you can also inject the id of the deployment (with +org.flowable.dmn.engine.test.DmnDeploymentId+_) into your test and lifecycle methods.
@@ -155,34 +155,6 @@ Taking all that in account, a JUnit 5 test looks as follows:
155
155
}
156
156
}
157
157
158
-
When writing JUnit 4 unit tests, the org.flowable.dmn.engine.test.FlowableDmnRule Rule can be used. Through this rule, the DMN engine and services are available through getters. Including this Rule will enable the use of the org.flowable.dmn.engine.test.DmnDeploymentAnnotation annotation (see above for an explanation of its use and configuration) and it will look for the default configuration file on the classpath. DMN engines are statically cached over multiple unit tests when using the same configuration resource.
159
-
It’s also possible to provide a custom engine configuration to the rule.
160
-
161
-
The following code snippet shows an example of using the JUnit 4 style of testing and the usage of the FlowableDmnRule (and passing an optional custom configuration):
162
-
163
-
**JUnit 4 test.**
164
-
165
-
public class MyDecisionTableTest {
166
-
167
-
@Rule
168
-
public FlowableDmnRule flowableDmnRule = new FlowableDmnRule("custom1.flowable.dmn.cfg.xml");
The DmnEngine is a thread-safe class and can easily be shared among multiple threads. In a web application, this means it is possible to create the DMN engine once when the container boots and shut down the engine when the container goes down.
0 commit comments