Skip to content
JUnit 5 Extension and TestEngine ideas
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs 0.11.10 release (previous 0.11.9) + release notes updated [ci skip] Feb 6, 2019
.travis.yml Add Single-File Source-Code Test Engine Jul 17, 2018
LICENSE Add TempDir annotation Feb 6, 2019
build.gradle Upgrade JUnit to 5.4-RC2 and introduce JimFS for testing Feb 6, 2019
gradlew Upgrade to Gradle 5.0 Dec 27, 2018


jdk11 travis Maven Central

This projects offers some proof-of-concept ideas implementing JUnit Jupiter's Extension API and JUnit Platform's TestEngine:

Brahms Overview

Download the latest JAR or depend via Maven:


or Gradle:

testCompile "de.sormuras:brahms:${brahms.version}"

Don't want to use the brahms API in your test code? Add a test runtime dependency will do just fine:

testRuntime "de.sormuras:brahms:${brahms.version}"

Resource Manager Extension

The resource manager extension provides hassle-free global, named, and "one-shot" resource management. You may use three different annotations at method parameters to declare in which mode a resource should be managed.

  • ResourceManager.@New - create an instance of the resource and close it when the context is teared down.
  • ResourceManager.@Shared - get or create an instance of the named resource
  • ResourceManager.@Singleton - get or create the single instance of the resource - same as @Shared(name =

@Shared and @Singleton resource are created on demand - the first parameter resolution request wins. Resource created be those annotation may be used and shared between different test classes! The attached resources are closed when the global Jupiter extension context store is closing.

Temporary Directory as Resource

Brahms provides Temporary as a resource supplier that creates and closes temporary directories.

class Tests { 
  void test(@New(Temporary) Path temp) {
	// do something with "temp"

@New resources supplied to the constructor of a test class are automatically cleaned up after the

class Tests {

  final Path temp;		
  Tests(@New(Temporary) Path temp) {
	this.temp = temp;
  void test() {
	// do something with "this.temp"

Use @TempDir, a composed annotation short-cut for @ResourceManager.New(Temporary.class):

class Tests { 
  void test(@TempDir Path temp) {
	// do something with "temp"

Custom Resource

Find samples of custom resources, like a declaring and sharing a WebServer and temporary & in-memory directory via JimFS, here:


☕ Brahms Maingine

NOTE: Development of Maingine is continued here:

Find classes that contain a public static void main(String[] args) method and execute them.


A simple main class will be executed in-process and any exception will cause the test to be marked as failed.

public class MainPlain {
  public static void main(String... args) {
    // ...

Customize @Main execution

Use the @Main annotation to customize the execution: pass arguments, set a display name, fork a java process with different VM parameters. Any exception will cause the test to be marked as failed.

public class MainTests {
  // No-args test run

  // Single argument test run

  // Multiple arguments test run
  @Main({"2", "3"})

  // Custom display name of test run
      displayName = "main with '${ARGS}' as args",
      value = {"3", "4", "5"})

  // Fork VM and launch with specific java/VM options
      displayName = "☕ ${ARGS}",
      value = {"6", "7"},
      java = @Java(options = {"-classpath", "${java.class.path}"}))

  public static void main(String... args) {
    var message = args.length == 0 ? "<no-args>" : String.join(", ", args);
    System.out.println("MainTests: " + message);

When forking, you may also expect a non-zero exit value:

public class SystemExit123 {

  	value = "123",
  	java = @Java(expectedExitValue = 123, options = {"-classpath", "${java.class.path}"}))              
  public static void main(String... args) {

📜 Brahms Single File Source Code TestEngine

NOTE: Development of SingleFileSourceCodeTestEngine is continued here:

Find .java source files that contain a public static void main(String[] args) method and execute them. For details see JEP 330.

class SingleFileSourceCodeProgram {
  public static void main(String... args) {
    // ...
You can’t perform that action at this time.