diff --git a/README.md b/README.md index 40b197d..8202de0 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ Camunda specific stages and scenarios for the BDD testing tool JGiven written in Kotlin. [![stable](https://img.shields.io/badge/lifecycle-STABLE-green.svg)](https://github.com/holisticon#open-source-lifecycle) +[![Camunda 7.20](https://img.shields.io/badge/Camunda%20Version-7.20-orange.svg)]([https://github.com/holisticon#open-source-lifecycle](https://docs.camunda.org/manual/7.20/)) [![Development braches](https://github.com/holunda-io/camunda-bpm-jgiven/workflows/Development%20braches/badge.svg)](https://github.com/holunda-io/camunda-bpm-jgiven/workflows) [![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) @@ -28,7 +29,7 @@ Add the following dependency to your Maven pom: io.holunda.testing camunda-bpm-jgiven - 0.4.0 + 1.20.0 test ``` @@ -39,17 +40,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 +79,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 +146,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 +186,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 +205,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) diff --git a/examples/basic-junit4/pom.xml b/examples/basic-junit4/pom.xml index 914997c..b8f29fd 100644 --- a/examples/basic-junit4/pom.xml +++ b/examples/basic-junit4/pom.xml @@ -6,7 +6,7 @@ io.holunda.testing camunda-bpm-jgiven-examples - 1.20.0 + 1.21.0 camunda-bpm-jgiven-examples-basic-junit4 diff --git a/examples/basic-junit5/pom.xml b/examples/basic-junit5/pom.xml index 610f6fa..29eacc5 100644 --- a/examples/basic-junit5/pom.xml +++ b/examples/basic-junit5/pom.xml @@ -6,7 +6,7 @@ io.holunda.testing camunda-bpm-jgiven-examples - 1.20.0 + 1.21.0 camunda-bpm-jgiven-examples-basic-junit5 @@ -41,9 +41,8 @@ test - org.camunda.bpm.extension + org.camunda.bpm camunda-bpm-junit5 - 1.1.0 test diff --git a/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/TestProcessEngine.kt b/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/TestProcessEngine.kt index be96eb4..7d8a99e 100644 --- a/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/TestProcessEngine.kt +++ b/examples/basic-junit5/src/test/kotlin/io/holunda/testing/examples/basic/junit5/TestProcessEngine.kt @@ -8,8 +8,8 @@ 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.bpm.engine.impl.history.HistoryLevel +import org.camunda.bpm.engine.test.junit5.ProcessEngineExtension import org.camunda.bpm.engine.test.mock.MockExpressionManager -import org.camunda.bpm.extension.junit5.test.ProcessEngineExtension import org.camunda.community.process_test_coverage.engine.platform7.ProcessCoverageConfigurator import org.camunda.community.process_test_coverage.junit5.platform7.ProcessEngineCoverageExtension import java.util.* diff --git a/examples/pom.xml b/examples/pom.xml index 8b9d724..fa45002 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -6,16 +6,16 @@ io.holunda.testing camunda-bpm-jgiven-parent - 1.20.0 + 1.21.0 camunda-bpm-jgiven-examples pom - 3.1.4 - 2.2.0 - 6.19.1 + 3.2.5 + 2.6.0 + 7.21.0 4.13.2 diff --git a/extension/pom.xml b/extension/pom.xml index 17b977b..f5c3a22 100644 --- a/extension/pom.xml +++ b/extension/pom.xml @@ -6,7 +6,7 @@ io.holunda.testing camunda-bpm-jgiven-parent - 1.20.0 + 1.21.0 camunda-bpm-jgiven diff --git a/pom.xml b/pom.xml index 01ef591..b190172 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ io.holunda.testing camunda-bpm-jgiven-parent - 1.20.0 + 1.21.0 pom @@ -15,13 +15,13 @@ - 7.20.0 - 1.3.0 - 3.24.2 - 1.3.0.0 + 7.21.0 + 1.3.1 + 3.26.0 + 1.3.1.0 17 - 1.9.10 + 2.0.0 true ${java.version} ${java.version} @@ -75,6 +75,12 @@ camunda-bpm-assert ${camunda.version} + + org.camunda.bpm + camunda-bpm-junit5 + ${camunda.version} + + @@ -110,7 +116,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.4.1 + 3.5.0 enforce-maven @@ -135,14 +141,14 @@ org.apache.maven.plugins maven-clean-plugin - 3.3.1 + 3.4.0 org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.13.0 UTF-8 ${java.version} @@ -177,13 +183,13 @@ org.apache.maven.plugins maven-surefire-plugin - 3.1.2 + 3.3.0 org.apache.maven.plugins maven-failsafe-plugin - 3.1.2 + 3.3.0 @@ -200,7 +206,7 @@ com.amashchenko.maven.plugin gitflow-maven-plugin - 1.20.0 + 1.21.0 master @@ -296,7 +302,7 @@ org.jetbrains.dokka dokka-maven-plugin - 1.9.0 + 1.9.20 test @@ -312,7 +318,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.4.0 + 3.6.0 generate-sources @@ -332,7 +338,7 @@ org.apache.maven.plugins maven-source-plugin - 3.3.0 + 3.3.1 attach-sources @@ -352,7 +358,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.1.0 + 3.2.4 --batch @@ -375,7 +381,7 @@ maven-deploy-plugin - 3.1.1 + 3.1.2 true @@ -383,7 +389,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.13 + 1.7.0 default-deploy @@ -403,7 +409,7 @@ maven-install-plugin - 3.1.1 + 3.1.2