camunda-community-hub / camunda-process-test-coverage

Community Extension Helper library to visualize which parts of a BPMN process have been covered by a process test.
https://camunda-community-hub.github.io/camunda-process-test-coverage/
Apache License 2.0
76 stars 44 forks source link
bpmn camunda coverage testing

Compatible with: Camunda Platform 7 Compatible with: Camunda Platform 8 Supported Camunda versions

Camunda Logo

Camunda Process Test Coverage

This Camunda Platform 7 and Platform 8 community extension visualises test process paths and checks your process model coverage ratio. Running typical JUnit tests now leaves html files in your build output. Just open one and check yourself what your test did:

Coverage report

Highlights

Just use it

Documentation

If you are interested in further documentation, please check our Documentation Page

Installation

Add a Maven test dependency to your project 0

JUnit5 (Platform 7 or Platform 8)

<dependency>
  <groupId>org.camunda.community.process_test_coverage</groupId>
  <artifactId>camunda-process-test-coverage-junit5-platform-7</artifactId>
  <!-- <artifactId>camunda-process-test-coverage-junit5-platform-8</artifactId> -->
  <version>${camunda-process-test-coverage.version}</version>
  <scope>test</scope>
</dependency>

Configuration

Use the ProcessCoverageInMemProcessEngineConfiguration, e.g. in your camunda.cfg.xml (only needed for Platform 7)

<bean id="processEngineConfiguration"
   class="org.camunda.community.process_test_coverage.engine.platform7.ProcessCoverageInMemProcessEngineConfiguration">
   ...
</bean>

Use the ProcessEngineCoverageExtension as your process engine JUnit extension (available for Platform 7 and Platform 8)

Either use @ExtendWith

Java

@ExtendWith(ProcessEngineCoverageExtension.class)
public class MyProcessTest

Kotlin

@ExtendWith(ProcessEngineCoverageExtension::class)
class MyProcessTest

or @RegisterExtension

If you register the extension on a non-static field, no class coverage and therefore no report will be generated. This is due to the fact, that an instance of the extension will be created per test method.

The extension provides a Builder for programmatic creation, which takes either a path to a configuration resource, a process engine configuration or if nothing is passed uses the default configuration resources path (camunda.cfg.xml).

The process engine configuration needs to be configured for test coverage. So use either the provided ProcessCoverageInMemProcessEngineConfiguration, SpringProcessWithCoverageEngineConfiguration or initialize the configuration with ProcessCoverageConfigurator.initializeProcessCoverageExtensions(configuration).

If you use Java:

@RegisterExtension
static ProcessEngineCoverageExtension extension = ProcessEngineCoverageExtension
        .builder().assertClassCoverageAtLeast(0.9).build();

If you prefer Kotlin:

companion object {
    @JvmField
    @RegisterExtension
    var extension: ProcessEngineCoverageExtension = ProcessEngineCoverageExtension
            .builder(ProcessCoverageInMemProcessEngineConfiguration())
            .assertClassCoverageAtLeast(1.0).build()
}

Running the tests

Running your JUnit tests now leaves html files for individual test methods as well as whole test classes in your project's target/process-test-coverage folder. Just open one, check yourself - and have fun with your process tests! :smile:

News and Noteworthy & Contributors

There are plenty of contributors to this project. Its initial design has been created by the WDW eLab GmbH and some others, but then the project has been abandoned for some time and received a full rewrite including the new architecture by members of flowcov.io squad and BPM craftsmen from Holisticon AG. We appreciate any help and effort you put into maintenance discussion and further development.

Please check the release notes of individual releases for the changes and involved contributors.

License

Apache License, Version 2.0. See LICENSE file.