Java
Tests
Tests are to be written using JUnit 4.12 and may use the preview features of the respective Java version. Tests are run with EJUnit in mono mode, which runs all test cases within a single process. Thus, a timeout in any test case causes the test execution to be aborted.
If the code under test requires assertions to be enabled, they have to be enabled through the
jvm.enable_asserts parameter. They must not be enabled from within the test code using a static
initializer block, such as:
public class SampleTest {
static {
ClassLoader.getSystemClassLoader().setDefaultAssertionStatus(true);
}
}
Enabling assertions in this way is error prone because the class loader state may already have been initialized before the test class is loaded. For example, if the test runner loads the code under test before executing the static initializer, the assertion setting will have no effect.
Code Coverage
The following tools are currently supported for collecting code coverage metrics:
- OpenClover (source code instrumentation)
- JaCoCo (bytecode instrumentation)
However, OpenClover is outdated and does not support newer Java language features, such as records. Although OpenClover officially supports only Java 8, it can also be used with newer Java versions as long as unsupported language features are not used.
The collection of code coverage can be enabled with the coverage.enabled parameter. The
instrumentation tool can be selected using the the coverage.tool parameter, which accepts either
jacoco or clover.
Environments
There are numerous environments for different Java versions (java17, java19, java20, java21,
java25). In these environments, the H2 database driver, MongoDB database driver, C/C++ compiler,
ANTLR, and various libraries (bson, jaxb) are typically installed. Refer to the Dockerfile of
the respective environment for their exact versions.