If you’re a fan of JUnit5 for testing on the JVM, we have good news — there’s a brand-new library available: camunda-bpm-junit5, published as a community extension for Camunda BPM. The project is now available on Maven central, so you can start testing your processes with the latest technology.

Getting started

To add the extension to your project, just add the Maven dependency to your pom file:

<dependency>
  <groupId>org.camunda.bpm.extension</groupId>
  <artifactId>camunda-bpm-junit5</artifactId>
  <version>1.0.0</version>
  <scope>test</scope>
</dependency>

Add the dependencies to JUnit 5 if you don’t already have them (they are included in the spring-boot-starter-test artifact):

<dependency>
  <groupId>org.junit.jupiter</groupId>
  <artifactId>junit-jupiter</artifactId>
  <version>5.6.2</version>
  <scope>test</scope>
</dependency>

To start testing you can extend your test class with the ProcessEngineExtension:

@ExtendWith(ProcessEngineExtension.class)
public class SimpleTestCase {
  ...
}

This injects the ProcessEngine configured in the camunda.cfg.xml file into your test class and you can use it right away:

public ProcessEngine processEngine;

If you need a more fine-grained setup of the process engine, you can register the extension with a custom configuration file like this:

@RegisterExtension
ProcessEngineExtension extension = ProcessEngineExtension.builder()
  .configurationResource("audithistory.camunda.cfg.xml")
  .build();

Then you can access the process engine from the extension:

RuntimeService runtimeService = extension.getProcessEngine().getRuntimeService();

Why make the jump to JUnit 5?

The goal of this extension is to allow you to use the latest technology for testing. During my journey, I honestly didn’t find any killer features of JUnit 5 that make you need to migrate to JUnit 5 right away.

But it makes a lot of things easier:

  • Clearer lifecycle annotation names (@BeforeEach, @BeforeAll, …)
  • Improved support for parameterized tests
  • Annotate tests with @DisplayName("my name") or @Disabled("for some reason")

Internally, JUnit 5 provides easier support for your own annotations. The internal implementation of the @Deployment annotation, to detect if it is used on a method or a class, became easier than the JUnit 4 support.

With this community extension, there is no reason to use legacy technology for your process tests anymore. It works well together with camunda-bpm-assert, as you can see in this example: https://github.com/camunda/camunda-bpm-junit5/tree/master/examples/camunda-bpm-assert

When you start converting your tests to JUnit 5, just remember that the @Test annotation has a new package and the import changed to:

import org.junit.jupiter.api.Test;

If you have questions or find any issues, please file them in the GitHub repository: https://github.com/camunda/camunda-bpm-junit5/issues. I’m looking forward to any feedback.

Happy testing!

Camunda Developer Community

Join Camunda’s global community of developers sharing code, advice, and meaningful experiences

  • Title slide that reads "Why Camunda 8"

    Why R-KOM Chose Camunda Platform 8

    In this blog series, we highlight the customers who have chosen to utilize Camunda Platform 8 and explore the challenges those companies are attempting to overcome using process orchestration. For the latest installment of Why Camunda 8, we spoke with R-KOM, a telecommunications company based in Regensburg, Germany. When R-KOM was founded in 1997, its shareholders pooled their telecommunications infrastructure, which had evolved over decades with utility networks for water, electricity, and gas. Initially, R-KOM’s services were limited to business and the public sector, but now it has developed further in line with demand. Over the years, the company’s high-performance infrastructure and a broad range of products have grown. Today, R-KOM has a number of city networks in Eastern Bavaria...

    Read more
  • Header image that reads, "Camunda Automation Platform 7.18.0-alpha4 Released

    Camunda Automation Platform 7.18.0-alpha4 Released

    We are pleased to announce the next alpha release of Camunda Platform Runtime 7.18. This release features the following improvements: Support for H2 2.1 Traditional Chinese translations are available Improved status monitoring of batch jobs Improved safety of executing a batch operation on the Batch Operation page 8 Bug Fixes You can download Camunda for free or run it with Docker. For a complete list of all improvements, take a look at the release notes. Please also see the list of known issues. If you want to dig in deeper, you can find the source code on GitHub. Support for H2 2.1 This release adds support for the H2 database in version 2.1, which provides fixes for vulnerabilities. Enterprise customers...

    Read more
  • A title slide that reads "Camunda Optimize 3.9.0 alpha3 Released

    Camunda Optimize 3.9.0 alpha3 Released

    We’re excited to announce a new release of Camunda Optimize. Camunda Optimize provides business activity monitoring for workflows, supporting continuous process improvement by providing transparency into your automated workflows and decisions. Business-friendly reports, dashboards, and alerts make it possible to identify process bottlenecks, improve end-to-end processes, and evaluate the success of your process automation initiative. In the rest of this post, we’ll highlight some of the new capabilities introduced in Optimize 3.9.0 alpha3. What’s new? Ease of adding new reports to dashboard Reports are added to dashboards to design an individual overview of the performance of your processes. Adding reports to dashboards was already possible with previous versions of Optimize, but now we’ve reduced the number of steps to do...

    Read more

Ready to get started?

Still have questions?