adam bien's blog

zunit: Zero-Dependency Java 25 Test Runner 📎

zunit is a zero-dependency, single-file Java 25 Script test runner. It discovers *Test.java source files and runs each directly via java --source 25. No compilation step, no JUnit, no build tool required — just run zunit and go.

A GreeterTest.java example:


void main() {
    var greeting = Greeter.greet("World");
    assert Objects.equals("Hello, World!", greeting) : "expected 'Hello, World!' but got: " + greeting;
}

Each test is a self-contained Java source script with a void main() method. Any thrown exception or non-zero exit code indicates test failure. Each test gets its own JVM — full execution isolation with zero shared state.

Run it with:

  1. zunit to auto-detect and run all tests,
  2. zunit -cp:zbo/app.jar for an explicit classpath
  3. zb && zunit to build with zb first.

zunit is available from: github.com/AdamBien/zunit

The corresponding airails.dev skill is available from: github.com/AdamBien/airails/tree/main/java/zunit