Skip to content

Commit

Permalink
Merge branch 'release/0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanzilske committed Mar 1, 2022
2 parents 99ace5d + c218234 commit eff3a7e
Show file tree
Hide file tree
Showing 22 changed files with 1,193 additions and 361 deletions.
14 changes: 14 additions & 0 deletions .github/release-notes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
changelog:
sections:
- title: ":rocket: Enhancements & Features"
labels: [ "Type: enhancement", "Type: documentation", "Type: example" ]
- title: ":bug: Bug Fixes"
labels: [ "Type: bug" ]
- title: ":hammer_and_wrench: Chore"
labels: [ "Type: dependencies" ]
issues:
exclude:
labels: [ "Type: Incorrect Repository", "Type: question" ]
contributors:
exclude:
names: [ "dependabot[bot]", "codacy-badger" ]
4 changes: 0 additions & 4 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,3 @@ jobs:
- name: Build with Maven
run: ./mvnw clean verify -U -B -T4

- name: Upolad coverage information
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
5 changes: 0 additions & 5 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,3 @@ jobs:
env:
OSS_CENTRAL_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
OSS_CENTRAL_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}

- name: Upolad coverage information
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/release-notes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Trigger the workflow on milestone events
on:
milestone:
types: [closed]
name: Milestone Closure
jobs:
create-release-notes:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Create Release Notes Markdown
uses: docker://decathlon/release-notes-generator-action:3.1.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
OUTPUT_FOLDER: temp_release_notes
USE_MILESTONE_TITLE: "true"
- name: Get the name of the created Release Notes file and extract Version
run: |
RELEASE_NOTES_FILE=$(ls temp_release_notes/*.md | head -n 1)
echo "RELEASE_NOTES_FILE=$RELEASE_NOTES_FILE" >> $GITHUB_ENV
VERSION=$(echo ${{ github.event.milestone.title }} | cut -d' ' -f2)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Create a Draft Release Notes on GitHub
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ env.VERSION }}
release_name: ${{ env.VERSION }}
body_path: ${{ env.RELEASE_NOTES_FILE }}
draft: true
187 changes: 117 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Camunda specific stages and scenarios for the BDD testing tool JGiven written in

[![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)
[![codecov](https://codecov.io/gh/holunda-io/camunda-bpm-jgiven/branch/master/graph/badge.svg)](https://codecov.io/gh/holunda-io/camunda-bpm-jgiven)

[![Project Stats](https://www.openhub.net/p/camunda-bpm-jgiven/widgets/project_thin_badge.gif)](https://www.openhub.net/p/camunda-bpm-jgiven)

Expand All @@ -14,85 +13,139 @@ Starting from 2012, we are preaching that processes are no units. Behavior-drive
underlying testing methodology of scenario-based testing is a way more adequate and convenient for writing
process (model) tests.

Our first attempts addressed testing frameworks Cucumber and JBehave. For JBehave we were even able to release
an official [Camunda BPM extension](https://github.com/camunda/camunda-bpm-jbehave). It turned out that the main problem
in using it, was error-prone writing of the test specifications in Gherkin and glue code in Java.
Our first attempts addressed testing frameworks Cucumber and JBehave. For JBehave we were able to release
an official [Camunda BPM extension](https://github.com/camunda/camunda-bpm-jbehave), but it turned out that the main problem
in using it, was error-prone writing of the test specifications in Gherkin (text files) and glue code them with Java.

This is, where [JGiven](http://jgiven.org/) comes on the scene, allowing to write both in Java or any other JVM language
by providing a nice API and later generating reports which are human readable.
by providing a nice API and later generating reports which are human-readable.

## Usage

Add the following dependency to your Maven pom:

<dependency>
<groupId>io.holunda.testing</groupId>
<artifactId>camunda-bpm-jgiven</artifactId>
<version>0.0.7</version>
<scope>test</scope>
</dependency>

```xml
<dependency>
<groupId>io.holunda.testing</groupId>
<artifactId>camunda-bpm-jgiven</artifactId>
<version>0.2.0</version>
<scope>test</scope>
</dependency>
```
## Features

JGiven supports separation of the glue code (application driver) into so-called [stages](http://jgiven.org/userguide/#_stages_and_state_sharing).
Stages contain assert and action methods and may be subclassed. This library provides a base class
`ProcessStage` for building your process testing stages. Here is how the test then looks like
(written in Kotlin):

### JUnit4

```kotlin
@Deployment(resources = [ApprovalProcessBean.RESOURCE])
open class ApprovalProcessTest : ScenarioTest<ApprovalProcessActionStage, ApprovalProcessActionStage, ApprovalProcessThenStage>() {

@get: Rule
val rule: ProcessEngineRule = StandaloneInMemoryTestConfiguration().rule()

@ScenarioState
val camunda = rule.processEngine

@Test
fun `should automatically approve`() {
val approvalRequestId = UUID.randomUUID().toString()
given()
.process_is_deployed(ApprovalProcessBean.KEY)
.and()
.process_is_started_for_request(approvalRequestId)
.and()
.approval_strategy_can_be_applied(Expressions.ApprovalStrategy.AUTOMATIC)
.and()
.automatic_approval_returns(Expressions.ApprovalDecision.APPROVE)
whenever()
.process_continues()
then()
.process_is_finished()
.and()
.process_has_passed(Elements.SERVICE_AUTO_APPROVE, Elements.END_APPROVED)
internal fun `should automatically approve`() {

val approvalRequestId = UUID.randomUUID().toString()

GIVEN
.process_is_deployed(ApprovalProcessBean.KEY)
.AND
.process_is_started_for_request(approvalRequestId)
.AND
.approval_strategy_can_be_applied(Expressions.ApprovalStrategy.AUTOMATIC)
.AND
.automatic_approval_returns(Expressions.ApprovalDecision.APPROVE)

WHEN
.process_continues()

THEN
.process_is_finished()
.AND
.process_has_passed(Elements.SERVICE_AUTO_APPROVE, Elements.END_APPROVED)

}
}
```

### JUnit5

```kotlin
@ExtendWith(ProcessEngineExtension::class)
@Deployment(resources = [ApprovalProcessBean.RESOURCE])
internal class ApprovalProcessTest :
ScenarioTest<ApprovalProcessActionStage, ApprovalProcessActionStage, ApprovalProcessThenStage>() {

@RegisterExtension
val extension = TestProcessEngine.DEFAULT

@ScenarioState
val camunda = extension.processEngine

@Test
internal fun `should automatically approve`() {

val approvalRequestId = UUID.randomUUID().toString()

GIVEN
.process_is_deployed(ApprovalProcessBean.KEY)
.AND
.process_is_started_for_request(approvalRequestId)
.AND
.approval_strategy_can_be_applied(Expressions.ApprovalStrategy.AUTOMATIC)
.AND
.automatic_approval_returns(Expressions.ApprovalDecision.APPROVE)

WHEN
.process_continues()

THEN
.process_is_finished()
.AND
.process_has_passed(Elements.SERVICE_AUTO_APPROVE, Elements.END_APPROVED)

And here is the corresponding stage:

open class ApprovalProcessActionStage : ProcessStage<ApprovalProcessActionStage, ApprovalProcessBean>() {

@BeforeStage
open fun `automock all delegates`() {
CamundaMockito.registerJavaDelegateMock(DETERMINE_APPROVAL_STRATEGY)
CamundaMockito.registerJavaDelegateMock(AUTOMATICALLY_APPROVE_REQUEST)
CamundaMockito.registerJavaDelegateMock(ApprovalProcessBean.Expressions.LOAD_APPROVAL_REQUEST)
}

open fun process_is_started_for_request(approvalRequestId: String): ApprovalProcessActionStage {
processInstanceSupplier = ApprovalProcessBean(camunda.processEngine)
processInstanceSupplier.start(approvalRequestId)
assertThat(processInstanceSupplier.processInstance).isNotNull
assertThat(processInstanceSupplier.processInstance).isStarted
return self()
}

fun approval_strategy_can_be_applied(approvalStrategy: String): ApprovalProcessActionStage {
getJavaDelegateMock(DETERMINE_APPROVAL_STRATEGY).onExecutionSetVariables(Variables.putValue(APPROVAL_STRATEGY, approvalStrategy))
return self()
}

fun automatic_approval_returns(approvalDecision: String): ApprovalProcessActionStage {
getJavaDelegateMock(AUTOMATICALLY_APPROVE_REQUEST).onExecutionSetVariables(Variables.putValue(APPROVAL_DECISION, approvalDecision))
return self()
}
}

}
```

Here is the corresponding stage, providing the steps used in the test:

```kotlin
class ApprovalProcessActionStage : ProcessStage<ApprovalProcessActionStage, ApprovalProcessBean>() {

@BeforeStage
fun `automock all delegates`() {
CamundaMockito.registerJavaDelegateMock(DETERMINE_APPROVAL_STRATEGY)
CamundaMockito.registerJavaDelegateMock(AUTOMATICALLY_APPROVE_REQUEST)
CamundaMockito.registerJavaDelegateMock(ApprovalProcessBean.Expressions.LOAD_APPROVAL_REQUEST)
}

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))
}
}
```

The resulting report:

![JGiven Process Report](docs/report.png)
Expand All @@ -115,12 +168,8 @@ If you have permissions to release, make sure all branches are fetched and run:
./mvnw gitflow:release-start
./mvnw gitflow:release-finish
from cli. This will update the poms of `develop` and `master` branches.
If you want to publish to central and have sufficient permissions, run

./mvnw clean deploy -Prelease -DskipExamples
on `master` branch. Don't forget to close and release repository on https://oss.sonatype.org/#stagingRepositories.
from cli. This will update the poms of `develop` and `master` branches
and start GitHub actions producing a new release.


### Current maintainers
Expand All @@ -130,5 +179,3 @@ on `master` branch. Don't forget to close and release repository on https://oss.
* [Jan Galinski](https://github.com/jangalinski)
* [Andre Hegerath](https://github.com/a-hegerath)
* [Stefan Zilske](https://github.com/stefanzilske)


81 changes: 81 additions & 0 deletions examples/basic-junit5/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>

<parent>
<groupId>io.holunda.testing</groupId>
<artifactId>camunda-bpm-jgiven-examples</artifactId>
<version>0.2.0</version>
</parent>

<artifactId>camunda-bpm-jgiven-examples-basic-junit5</artifactId>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.camunda.bpm.extension.mockito</groupId>
<artifactId>camunda-bpm-mockito</artifactId>
<version>5.16.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.camunda.bpm.assert</groupId>
<artifactId>camunda-bpm-assert-assertj3-11-1</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.camunda.bpm.assert</groupId>
<artifactId>camunda-bpm-assert</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.camunda.bpm.extension</groupId>
<artifactId>camunda-bpm-junit5</artifactId>
<version>1.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.holunda.testing</groupId>
<artifactId>camunda-bpm-jgiven</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.camunda.bpm.extension</groupId>
<artifactId>camunda-bpm-process-test-coverage</artifactId>
<version>0.4.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<!-- kotlin compiler -->
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
</plugin>
<plugin>
<!-- report with JGiven -->
<groupId>com.tngtech.jgiven</groupId>
<artifactId>jgiven-maven-plugin</artifactId>
</plugin>
</plugins>
</build>


</project>
Loading

0 comments on commit eff3a7e

Please sign in to comment.