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 Cloud Console Go Client Library

    When working with multiple projects and multiple Cloud Services automation becomes a must. Camunda Cloud resources such as Zeebe Clusters and Camunda Operate are no different from other components such as Databases, or Message brokers, these need to be provisioned for your applications to connect with. This project allows you to connect to the Camunda Cloud Console using the Go language or a command-line tool, allowing you to create automation around when remote environments are created and destroyed. You can connect to these APIs using any language as these APIs are just REST endpoints, but if you have automated pipelines using a command-line tool might be the best fit for you.  This project provides a binary that you can download...

    Read more
  • The Journey from Camunda BPM to Camunda...

    You might have noticed something a little different about our recent release announcement: Camunda BPM is now Camunda Platform. We’ve renamed our process automation solution to better reflect our mission to help organizations automate any process, anywhere. And, to be perfectly honest, we are also keeping up with what we’re hearing in the field — many of our users and customers already informally refer to “Camunda Platform” or even just “the platform” or simply “Camunda” when talking about the product. During CamundaCon 2020.2, our CEO, Jakob Freund, explained that processes are the algorithms that determine how an organization runs. They define how we work within our own team or across teams, and they influence the way we deal with our...

    Read more
  • More From the Camunda Platform: Assert &...

    Alongside our Camunda Platform Runtime 7.15.0 release, we’re excited to announce the following releases: Camunda Platform Assert External Task Client (for Java) You can read all about the Camunda Platform Runtime 7.15.0 release in the dedicated blog post. Camunda Platform Assert Camunda Platform Assert (formerly Camunda BPM Assert) helps you assert the status of your BPMN processes when driving them forward in your typical unit test methods. We have released two versions this time. Assert 10.0.0 is bound to Camunda Platform Runtime 7.15.0, while Assert 9.0.0 will be used by version 7.14.0 of the product. We upgraded the version of AssertJ to 3.18.1, which is the current version used in Spring Boot 2.4.x and therefore also the latest Camunda Spring...

    Read more