All Projects → camunda-community-hub → bpmn-spec

camunda-community-hub / bpmn-spec

Licence: Apache-2.0 license
A tool to run tests for BPMN processes on Zeebe

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to bpmn-spec

zeeqs
Query API for aggregated Zeebe data
Stars: ✭ 37 (+32.14%)
Mutual labels:  zeebe, zeebe-tool
zeebe-simple-monitor
A monitoring application to show insides of Zeebe for developers
Stars: ✭ 110 (+292.86%)
Mutual labels:  zeebe, zeebe-tool
Camunda.api.client
Camunda REST API Client for .NET platform
Stars: ✭ 87 (+210.71%)
Mutual labels:  bpmn
Bpmn Moddle
Read and write BPMN 2.0 XML from JavaScript.
Stars: ✭ 221 (+689.29%)
Mutual labels:  bpmn
Camunda Bpm Platform
Flexible framework for workflow and decision automation with BPMN and DMN. Integration with Spring, Spring Boot, CDI.
Stars: ✭ 2,390 (+8435.71%)
Mutual labels:  bpmn
Butterfly
🦋Butterfly,A JavaScript/React/Vue2 Diagramming library which concentrate on flow layout field. (基于JavaScript/React/Vue2的流程图组件)
Stars: ✭ 2,343 (+8267.86%)
Mutual labels:  bpmn
Bpe
💠 BPE: Business Process Engine
Stars: ✭ 178 (+535.71%)
Mutual labels:  bpmn
Bpmn Js Token Simulation Plugin
Token simulation as a plugin for the Camunda Modeler
Stars: ✭ 74 (+164.29%)
Mutual labels:  bpmn
Quintessential-Tasklist-Zeebe
The quintessential Zeebe tasklist for BPMN Human tasks with Drag and Drop Form builder, client and server side validations, and drop in Form Rendering
Stars: ✭ 34 (+21.43%)
Mutual labels:  zeebe
Django Lb Workflow
Reusable workflow library for Django
Stars: ✭ 153 (+446.43%)
Mutual labels:  bpmn
Imixs Workflow
The open source technology for business process management
Stars: ✭ 218 (+678.57%)
Mutual labels:  bpmn
Zeebe
Distributed Workflow Engine for Microservices Orchestration
Stars: ✭ 2,165 (+7632.14%)
Mutual labels:  bpmn
Kft Activiti Demo
Demo for workflow framework and BPM platform -- Activiti
Stars: ✭ 1,548 (+5428.57%)
Mutual labels:  bpmn
Kogito Runtimes
Kogito Runtimes - Kogito is a cloud-native business automation technology for building cloud-ready business applications.
Stars: ✭ 188 (+571.43%)
Mutual labels:  bpmn
Kogito Examples
Kogito examples - Kogito is a cloud-native business automation technology for building cloud-ready business applications.
Stars: ✭ 96 (+242.86%)
Mutual labels:  bpmn
Workflow
基于Activiti5 定制化中国式工作流系统,定制化的流程设计器,添加自定义属性。
Stars: ✭ 226 (+707.14%)
Mutual labels:  bpmn
Jbpm
a Business Process Management (BPM) Suite
Stars: ✭ 1,226 (+4278.57%)
Mutual labels:  bpmn
Orienteer
Business Application Platform
Stars: ✭ 128 (+357.14%)
Mutual labels:  bpmn
Viewflow
Reusable workflow library for Django
Stars: ✭ 2,136 (+7528.57%)
Mutual labels:  bpmn
tau
A Micro (1k lines of code) Unit Test Framework for C/C++
Stars: ✭ 121 (+332.14%)
Mutual labels:  test-framework

Zeebe Spec

License

Compatible with: Camunda Platform 8

A tool to run tests for BPMN processes on Zeebe.

The idea

Install

The tests can be run by calling the SpecRunner directly in code, or by using the JUnit integration.

JUnit Integration

  1. Add the Maven dependencies:
<dependency>
  <groupId>org.camunda.community</groupId>
  <artifactId>zeebe-spec-junit-extension</artifactId>
  <version>3.0.0</version>
  <scope>test</scope>
</dependency>
  1. Put the spec and BPMN files in the resource folder (e.g. /src/test/resources/)

  2. Write a JUnit test class like the following (here in Kotlin):

package my.package

import org.camunda.community.zeebe.spec.SpecRunner
import org.camunda.community.zeebe.spec.assertj.SpecAssertions.assertThat
import org.junit.jupiter.params.ParameterizedTest

@ZeebeSpecRunner
class BpmnTest(private val specRunner: SpecRunner) {
 
    @ParameterizedTest
    @ZeebeSpecSource(specDirectory = "specs")
    fun `should pass all tests`(spec: ZeebeSpecTestCase) {

        val testResult = specRunner.runSingleTestCase(spec.testCase)

        assertThat(testResult).isSuccessful()
    }

}
  1. Run the JUnit test class

Junit test results

Usage

Example spec with one test case:

YAML Spec

testCases:
  - name: fulfill-condition
    description: should fulfill the condition and enter the upper task
    instructions:
      - action: create-instance
        args:
          bpmn_process_id: exclusive-gateway
      - action: complete-task
        args:
          job_type: a
          variables: '{"x":8}'
      - verification: element-instance-state
        args:
          element_name: B
          state: activated

Kotlin Spec

val testSpecFulfillCondition =
    testSpec {
        testCase(
            name = "fulfill-condition",
            description = "should fulfill the condition and enter the upper task"
        ) {
            createInstance(bpmnProcessId = "exclusive-gateway")

            completeTask(jobType = "a", variables = mapOf("x" to 8))

            verifyElementInstanceState(
                selector = byName("B"),
                state = ElementInstanceState.ACTIVATED
            )
        }
    }

The Spec

A spec is written in a YAML text format, or alternative in Kotlin code. It contains the following elements:

  • testCases: a list of test cases, each test case contains the following elements
    • name: the (short) name of the test case
    • description: (optional) an additional description of the test case
    • instructions: a list of actions and verifications that are applied in order

Actions

Actions drive the test case forward until the result is checked using the verifications. The following actions are available:

create-instance

Create a new instance of a process.

  • bpmn_process_id: the BPMN process id of the process
  • variables: (optional) initial variables/payload to create the instance with
  • process_instance_alias: (optional) an alias that can be used in following actions and verifications to reference this instance. This can be useful if multiple instances are created.
      - action: create-instance
        args:
          bpmn_process_id: demo
          variables: '{"x":1}'

complete-task

Complete tasks of a given type.

  • job_type: the type or identifier of the job/task
  • variables: (optional) variables/payload to complete the tasks with
      - action: complete-task
        args:
          job_type: a
          variables: '{"y":2}'

throw-error

Throw error events for tasks of a given type.

  • job_type: the type or identifier of the job/task
  • error_code: the error code that is used to correlate the error to an catch event
  • error_message: (optional) an additional message of the error event
      - action: throw-error
        args:
          job_type: b
          error_code: error-1

publish-message

Publish a new message event.

  • message_name: the name of the message
  • correlation_key: the key that is used to correlate the message to a process instance
  • variables: (optional) variables/payload to publish the message with
      - action: publish-message
        args:
          message_name: message-1
          correlation_key: key-1
          variables: '{"z":3}'

cancel-instance

Cancel/terminate a process instance.

  • process_instance: (optional) the alias of a process instance that is canceled. The alias is defined in the create-instance action. If only one instance is created then the alias is not required.
      - action: cancel-instance
        args:
          process_instance: process-1

await-element-instance-state

Await until an element of the process instance is in the given state.

  • state: the state of the element to wait for. Must be one of: activated | completed | terminated | taken
  • element_name: (optional) the name of the element in the process
  • element_id: (optional) as an alternative to the name, the element can be identified by its id in the process
  • process_instance: (optional) the alias of a process instance. The alias is defined in the create-instance action. If only one instance is created then the alias is not required.
      - action: await-element-instance-state
        args:
          element_name: B
          state: activated

Verifications

Verifications check the result of the test case after all actions are applied. The following verifications are available:

process-instance-state

Check if the process instance is in a given state.

  • state: the state of the process instance. Must be one of: activated | completed | terminated
  • process_instance: (optional) the alias of a process instance. The alias is defined in the create-instance action. If only one instance is created then the alias is not required.
      - verification: process-instance-state
        args:
          state: completed

element-instance-state

Check if an element of the process instance is in a given state.

  • state: the state of the element. Must be one of: activated | completed | terminated | taken
  • element_name: (optional) the name of the element in the process
  • element_id: (optional) as an alternative to the name, the element can be identified by its id in the process
  • process_instance: (optional) the alias of a process instance. The alias is defined in the create-instance action. If only one instance is created then the alias is not required.
      - verification: element-instance-state
        args:
          element_name: B
          state: activated

process-instance-variable

Check if the process instance has a variable with the given name and value. If the element name or id is set then it checks only for (local) variables in the scope of the element.

  • name: the name of the variable
  • value: the value of the variable
  • element_name: (optional) the name of the element in the process that has the variable in its scope
  • element_id: (optional) as an alternative to the name, the element can be identified by its id in the process
  • process_instance: (optional) the alias of a process instance. The alias is defined in the create-instance action. If only one instance is created then the alias is not required.
      - verification: process-instance-variable
        args:
          name: x
          value: '1'

no-process-instance-variable

Check if the process instance has no variable with the given name. If the element name or id is set then it checks only for (local) variables in the scope of the element.

  • name: the name of the variable
  • element_name: (optional) the name of the element in the process that has the variable in its scope
  • element_id: (optional) as an alternative to the name, the element can be identified by its id in the process
  • process_instance: (optional) the alias of a process instance. The alias is defined in the create-instance action. If only one instance is created then the alias is not required.
      - verification: no-process-instance-variable
        args:
          name: y
          element_name: B

incident-state

Check if the process instance has an incident in the given state. If the element name or id is set then it checks only for incidents in the scope of the element.

  • state: the state of the incident. Must be one of: created | resolved
  • errorType: the type/classifier of the incident
  • errorMessage: (optional) the error message of the incident
  • element_name: (optional) the name of the element in the process that has the incident in its scope
  • element_id: (optional) as an alternative to the name, the element can be identified by its id in the process
  • process_instance: (optional) the alias of a process instance. The alias is defined in the create-instance action. If only one instance is created then the alias is not required.
      - verification: incident-state
        args:
          error_type: EXTRACT_VALUE_ERROR
          error_message: "failed to evaluate expression 'key': no variable found for name 'key'"
          state: created
          element_name: B
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].