Jimfs support for JUnit Jupiter's `TempDirFactory`
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 296
- Avg merge
- 9m
- Merged PRs (30d)
- 7
Description
Starting from [version 5.10](https://junit.org/junit5/docs/5.10.0/release-notes/index.html#release-notes), JUnit 5 offers a [`TempDirFactory` SPI](https://junit.org/junit5/docs/5.10.0/user-guide/#writing-tests-built-in-extensions-TempDirectory) for customizing how temporary directories are created via the `@TempDir` annotation.
The SPI allows libraries like Jimfs to provide their own implementation, which can be used:
* On each `@TempDir` annotation via the `factory` attribute, e.g.:
```java
class MyTest {
@TempDir(factory = JimfsTempDirFactory.class)
private Path tempDir;
...
}
```
* As a meta-annotation, e.g.:
```java
@Target({ ANNOTATION_TYPE, FIELD, PARAMETER })
@Retention(RUNTIME)
@TempDir(factory = JimfsTempDirFactory.class)
@interface JimfsTempDir {
}
class MyTest {
@JimfsTempDir
private Path tempDir;
...
}
```
* Globally, via a configuration parameter, e.g.:
```
junit.jupiter.tempdir.factory.default=com.google.common.jimfs.junit.jupiter.JimfsTempDirFactory
```
You might notice that the JUnit documentation already refers to Jimfs to demonstrate certain use cases.
Would you consider first-party support for such a feature, providing your own factory implementation and maybe even meta-annotation(s)?
_Disclaimer: I authored most of the `TempDirFactory` changes so happy to hear your feedback and report back improvements, if you see any_ 🙂
Contributor guide
Assessment
This issue has not been assessed yet.