Decorative site banner
Project icon

com.io7m.zelador

  • About
  • Releases
  • Manual
  • Sources
  • License
  • Issues
Maven Central Version Maven Snapshot Code Coverage

zelador


A minimalist JUnit 5 extension to register AutoCloseable resources that will be destroyed after tests finish executing.

Features


  • Written in pure Java 21.
  • OSGi ready.
  • JPMS ready.
  • ISC license.
  • High-coverage automated test suite.

Motivation


For whatever reason, JUnit 5 does not include any utility to register per-test resources and automatically have them cleaned up.

The zelador package provides a tiny JUnit 5 extension that allows for registering AutoCloseable objects that must be closed after tests finish executing.

Building


$ mvn clean verify

Usage


Annotate your test suite with @ExtendWith(ZeladorExtension.class). This will allow tests to get access to an injected CloseableResourcesType instance that can be used to register resources to be closed.

@ExtendWith(ZeladorExtension.class) public final class ExampleTest { @Test public void test0( final CloseableResourcesType resources) { var output = resources.addPerTestResource(Files.newOutputStream(...)); ... } @Test public void test1( final CloseableResourcesType resources) { var output = resources.addPerTestClassResource(Files.newOutputStream(...)); ... } }

Resources added with addPerTestResource will be closed after the individual test has finished (as if it had been closed in an @AfterEach method).

Resources added with addPerTestClassResource will be closed after all tests in the class have finished (as if it had been closed in an @AfterAll method).

AutoCloseable is a functional interface and, as such, it's trivial to pass objects to the CloseableResourcesType class that do not implement AutoCloseable by simply using a method reference:

class NotReallyCloseable { public void finish() { ... } } NotReallyCloseable x; resources.addPerTestResource(x::finish);

Releases & Development Snapshots


Releases


You can subscribe to the atom feed to be notified of project releases.

The most recently released version of the package is 1.0.0.

1.0.0 Release (2024-05-10Z)

  • Initial public release.

The compiled artifacts for the release (and all previous releases) are available on Maven Central.

Maven Modules


<dependency> <group>com.io7m.zelador</group> <artifactId>com.io7m.zelador.test_extension</artifactId> <version>1.0.0</version> </dependency><dependency> <group>com.io7m.zelador</group> <artifactId>com.io7m.zelador.tests</artifactId> <version>1.0.0</version> </dependency>

Development Snapshots


At the time of writing, the current unstable development version of the package is 1.0.1-SNAPSHOT.

Development snapshots may be available in the Central Portal Snapshots repository. Snapshots are published to this repository every time the project is built by the project's continuous integration system, but snapshots do expire after around ninety days and so may or may not be available depending on when a build of the package was last triggered.

Manual


This project does not have any user manuals or other documentation beyond what might be present on the page above.

Sources


This project uses Git to manage source code.

Repository: https://www.github.com/io7m-com/zelador

$ git clone --recursive https://www.github.com/io7m-com/zelador

Issues


This project uses GitHub Issues to track issues.

License


Copyright © 2023 Mark Raynsford <code@io7m.com> https://www.io7m.com Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Last Updated 2025-08-09T14:59:07Z