diff --git a/README.md b/README.md index 40b197d..24896fa 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Add the following dependency to your Maven pom: io.holunda.testing camunda-bpm-jgiven - 0.4.0 + 1.20.0 test ``` @@ -39,17 +39,18 @@ Stages contain assert and action methods and may be subclassed. This library pro `ProcessStage` for building your process testing stages. Here is how the test then looks like (written in Kotlin): -### JUnit4 +### JUnit5 ```kotlin @Deployment(resources = [ApprovalProcessBean.RESOURCE]) -open class ApprovalProcessTest : ScenarioTest() { +internal class ApprovalProcessTest : + ScenarioTest() { - @get: Rule - val rule: ProcessEngineRule = StandaloneInMemoryTestConfiguration().rule() + @RegisterExtension + val extension = TestProcessEngine.DEFAULT @ScenarioState - val camunda = rule.processEngine + val camunda = extension.processEngine @Test fun`should automatically approve`() { @@ -77,49 +78,46 @@ open class ApprovalProcessTest : ScenarioTest() { -and add the following content into your `camunda.cfg.xml`: + @BeforeStage + fun `automock all delegates`() { + CamundaMockito.registerJavaDelegateMock(DETERMINE_APPROVAL_STRATEGY) + CamundaMockito.registerJavaDelegateMock(AUTOMATICALLY_APPROVE_REQUEST) + CamundaMockito.registerJavaDelegateMock(ApprovalProcessBean.Expressions.LOAD_APPROVAL_REQUEST) + } -```xml - + fun process_is_started_for_request(approvalRequestId: String) = step { + processInstanceSupplier = ApprovalProcessBean(camunda.processEngine) + processInstanceSupplier.start(approvalRequestId) + assertThat(processInstanceSupplier.processInstance).isNotNull + assertThat(processInstanceSupplier.processInstance).isStarted + } - + fun approval_strategy_can_be_applied(approvalStrategy: String) = step { + getJavaDelegateMock(DETERMINE_APPROVAL_STRATEGY).onExecutionSetVariables(Variables.putValue(APPROVAL_STRATEGY, approvalStrategy)) + } - - - - + fun automatic_approval_returns(approvalDecision: String) = step { + getJavaDelegateMock(AUTOMATICALLY_APPROVE_REQUEST).onExecutionSetVariables(Variables.putValue(APPROVAL_DECISION, approvalDecision)) + } +} ``` - -### JUnit5 +### JUnit4 ```kotlin @Deployment(resources = [ApprovalProcessBean.RESOURCE]) -internal class ApprovalProcessTest : - ScenarioTest() { +open class ApprovalProcessTest : ScenarioTest() { - @RegisterExtension - val extension = TestProcessEngine.DEFAULT + @get: Rule + val rule: ProcessEngineRule = StandaloneInMemoryTestConfiguration().rule() @ScenarioState - val camunda = extension.processEngine + val camunda = rule.processEngine @Test fun`should automatically approve`() { @@ -147,35 +145,37 @@ internal class ApprovalProcessTest : } ``` -Here is the corresponding stage, providing the steps used in the test: +If you want to collect process test coverage during the test run, make sure to replace your rule declaration by the following: ```kotlin -class ApprovalProcessActionStage : ProcessStage() { + companion object { + @get: ClassRule + @JvmStatic + val processEngineRule: ProcessEngineRule = TestCoverageProcessEngineRuleBuilder.create().build() +} - @BeforeStage - fun `automock all delegates`() { - CamundaMockito.registerJavaDelegateMock(DETERMINE_APPROVAL_STRATEGY) - CamundaMockito.registerJavaDelegateMock(AUTOMATICALLY_APPROVE_REQUEST) - CamundaMockito.registerJavaDelegateMock(ApprovalProcessBean.Expressions.LOAD_APPROVAL_REQUEST) - } +@get:Rule +val rule: ProcessEngineRule = processEngineRule - fun process_is_started_for_request(approvalRequestId: String) = step { - processInstanceSupplier = ApprovalProcessBean(camunda.processEngine) - processInstanceSupplier.start(approvalRequestId) - assertThat(processInstanceSupplier.processInstance).isNotNull - assertThat(processInstanceSupplier.processInstance).isStarted - } +``` - fun approval_strategy_can_be_applied(approvalStrategy: String) = step { - getJavaDelegateMock(DETERMINE_APPROVAL_STRATEGY).onExecutionSetVariables(Variables.putValue(APPROVAL_STRATEGY, approvalStrategy)) - } +and add the following content into your `camunda.cfg.xml`: - fun automatic_approval_returns(approvalDecision: String) = step { - getJavaDelegateMock(AUTOMATICALLY_APPROVE_REQUEST).onExecutionSetVariables(Variables.putValue(APPROVAL_DECISION, approvalDecision)) - } -} +```xml + + + + + + + + ``` + The resulting report: ![JGiven Process Report](docs/report.png) @@ -185,7 +185,10 @@ Interested? Check out the examples. ## License -APACHE 2.0 +This library is developed under + +[![Apache 2.0 License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](/LICENSE) + ## Contribution @@ -201,11 +204,3 @@ If you have permissions to release, make sure all branches are fetched and run: from cli. This will update the poms of `develop` and `master` branches and start GitHub actions producing a new release. - -### Current maintainers - -* [Simon Zambrovski](https://github.com/zambrovski) -* [Simon Sprünker](https://github.com/srsp) -* [Jan Galinski](https://github.com/jangalinski) -* [Andre Hegerath](https://github.com/a-hegerath) -* [Stefan Zilske](https://github.com/stefanzilske)