|
1 | | -ERROR com.io7m.ghrepostools.Main : The specified command does not exist. |
2 | | - Command : README |
3 | | - Error Code : command-nonexistent |
4 | | - |
5 | | -DEBUG com.io7m.ghrepostools.Main : Exception: |
6 | | -com.io7m.quarrel.core.QException: The specified command does not exist. |
7 | | - at com.io7m.quarrel.core.QApplication.parseExpanded(QApplication.java:244) |
8 | | - at com.io7m.quarrel.core.QApplication.parse(QApplication.java:152) |
9 | | - at com.io7m.quarrel.core.QApplicationType.run(QApplicationType.java:94) |
10 | | - at com.io7m.ghrepostools.Main.run(Main.java:126) |
11 | | - at com.io7m.ghrepostools.Main.mainExitless(Main.java:110) |
12 | | - at com.io7m.ghrepostools.Main.main(Main.java:95) |
| 1 | +zelador |
| 2 | +=== |
| 3 | + |
| 4 | +[](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.io7m.zelador%22) |
| 5 | +[](https://central.sonatype.com/repository/maven-snapshots/com/io7m/zelador/) |
| 6 | +[](https://codecov.io/gh/io7m-com/zelador) |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +| JVM | Platform | Status | |
| 12 | +|-----|----------|--------| |
| 13 | +| OpenJDK (Temurin) Current | Linux | [](https://www.github.com/io7m-com/zelador/actions?query=workflow%3Amain.linux.temurin.current)| |
| 14 | +| OpenJDK (Temurin) LTS | Linux | [](https://www.github.com/io7m-com/zelador/actions?query=workflow%3Amain.linux.temurin.lts)| |
| 15 | +| OpenJDK (Temurin) Current | Windows | [](https://www.github.com/io7m-com/zelador/actions?query=workflow%3Amain.windows.temurin.current)| |
| 16 | +| OpenJDK (Temurin) LTS | Windows | [](https://www.github.com/io7m-com/zelador/actions?query=workflow%3Amain.windows.temurin.lts)| |
| 17 | + |
| 18 | +## Repository Relocation |
| 19 | + |
| 20 | +Development of this project has moved to an |
| 21 | +[open-source but not open-contribution](https://sqlite.org/copyright.html#notopencontrib) |
| 22 | +model. |
| 23 | + |
| 24 | +Source code and commits will remain publicly available perpetually, but issues |
| 25 | +and/or pull requests will be rejected and/or ignored. Additionally, this project |
| 26 | +will now only be available via a read-only mirror at: |
| 27 | + |
| 28 | + https://codeberg.org/io7m-com/zelador |
| 29 | + |
| 30 | + |
| 31 | +## zelador |
| 32 | + |
| 33 | +A minimalist JUnit 5 extension to register `AutoCloseable` resources that |
| 34 | +will be destroyed after tests finish executing. |
| 35 | + |
| 36 | +### Features |
| 37 | + |
| 38 | + * Written in pure Java 21. |
| 39 | + * [OSGi](https://www.osgi.org/) ready. |
| 40 | + * [JPMS](https://en.wikipedia.org/wiki/Java_Platform_Module_System) ready. |
| 41 | + * ISC license. |
| 42 | + * High-coverage automated test suite. |
| 43 | + |
| 44 | +### Motivation |
| 45 | + |
| 46 | +For whatever reason, [JUnit 5](https://junit.org/junit5/) does not include |
| 47 | +any utility to register per-test resources and automatically have them |
| 48 | +cleaned up. |
| 49 | + |
| 50 | +The `zelador` package provides a tiny [JUnit 5](https://junit.org/junit5/) |
| 51 | +extension that allows for registering `AutoCloseable` objects that must be |
| 52 | +closed after tests finish executing. |
| 53 | + |
| 54 | +### Building |
| 55 | + |
| 56 | +``` |
| 57 | +$ mvn clean verify |
| 58 | +``` |
| 59 | + |
| 60 | +### Usage |
| 61 | + |
| 62 | +Annotate your test suite with `@ExtendWith(ZeladorExtension.class)`. This |
| 63 | +will allow tests to get access to an injected `CloseableResourcesType` |
| 64 | +instance that can be used to register resources to be closed. |
| 65 | + |
| 66 | +``` |
| 67 | +@ExtendWith(ZeladorExtension.class) |
| 68 | +public final class ExampleTest |
| 69 | +{ |
| 70 | + @Test |
| 71 | + public void test0( |
| 72 | + final CloseableResourcesType resources) |
| 73 | + { |
| 74 | + var output = resources.addPerTestResource(Files.newOutputStream(...)); |
| 75 | + ... |
| 76 | + } |
| 77 | +
|
| 78 | + @Test |
| 79 | + public void test1( |
| 80 | + final CloseableResourcesType resources) |
| 81 | + { |
| 82 | + var output = resources.addPerTestClassResource(Files.newOutputStream(...)); |
| 83 | + ... |
| 84 | + } |
| 85 | +} |
| 86 | +``` |
| 87 | + |
| 88 | +Resources added with `addPerTestResource` will be closed after the individual |
| 89 | +test has finished (as if it had been closed in an `@AfterEach` method). |
| 90 | + |
| 91 | +Resources added with `addPerTestClassResource` will be closed after all tests |
| 92 | +in the class have finished (as if it had been closed in an `@AfterAll` method). |
| 93 | + |
| 94 | +`AutoCloseable` is a functional interface and, as such, it's trivial to pass |
| 95 | +objects to the `CloseableResourcesType` class that do not implement |
| 96 | +`AutoCloseable` by simply using a method reference: |
| 97 | + |
| 98 | +``` |
| 99 | +class NotReallyCloseable { |
| 100 | + public void finish() { ... } |
| 101 | +} |
| 102 | +
|
| 103 | +NotReallyCloseable x; |
| 104 | +
|
| 105 | +resources.addPerTestResource(x::finish); |
| 106 | +``` |
| 107 | + |
| 108 | + |
0 commit comments