JUnit 5 extension

The BonitaTests extension is the entry point to create Bonita integration tests. It allows to specify some behaviors, and to inject the BonitaTestToolkit into the test methods.

Integrations tests are built upon the Bonita Test Toolkit, based on the open-source Bonita Java Client.
The Bonita Test Toolkit is only available for Enterprise, Performance, Efficiency, and Teamwork editions.

Create the Bonita test extension

The Bonita test extension is a JUnit 5 extension, it can be registered using the annotation @BonitaTests.

The extension can be registered through the annotation BonitaTests or manually.

Register the extension using the annotation BonitaTests

This annotation has to be added on the test class.

@BonitaTests
class ProcessIT {
    ...
}

Register the extension manually

The extension can be registered manually, using the JUnit 5 annotation RegisterExtension.

class ProcessIT {

    @RegisterExtension
    static BonitaTestExtension bonitaExtension = new BonitaTestExtension();

    ...
}

Inject BonitaTestToolkit

Once the extension registered, you can inject a BonitaTestToolkit instance as a test method parameter.

@BonitaTests(disableReport = false) (1)
class ProcessIT {

    @BeforeAll
    static void beforeAllTests(BonitaTestToolkit toolkit){
        toolkit.deleteBDMContent();
    }

    @BeforeEach
    void beforeEachTests(BonitaTestToolkit toolkit){
        toolkit.deleteProcessInstances();
    }

    @Test
    void testMyProcess(BonitaTestToolkit toolkit){
        var myProcess = toolkit.getProcessDefinition("MyProcess");
        ...
    }

}
1 false is the default value, if you want to disable the generated HTML reports, set it to true.

Configure a logger

The Bonita test toolkit rely on SLF4J 2.x logger API. You may plug the SLF4J implementation of your choice in your project.

Logback example

Add the logback-classic dependency in your pom.xml
<dependencies>
    ...
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.4.11</version>
        <scope>test</scope>
    </dependency>
</dependencies>
Add a logback.xml file in the src/test/resources folder
<configuration>

  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <!-- encoders are assigned the type
         ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
    <encoder>
      <pattern>%d{HH:mm:ss.SSS} [%thread] %highlight([%level]) %logger{36} - %msg%n</pattern>
    </encoder>
  </appender>

  <root level="warn">
    <appender-ref ref="STDOUT" />
  </root>

  <logger name="org.bonitasoft.web.client" level="warn" />
  <logger name="com.bonitasoft.test.toolkit" level="info" /> (1)

  <!-- Replace with the package containing your tests-->
  <logger name="com.company.project.test" level="info" />

</configuration>
1 You may use the DEBUG level to enhance the console output with contract content when instantiating a process or executing a task.