MA
marschall/memoryfilesystem-junit-provider
A Memoryfilesystem based @TempDir provider for JUnit
Memoryfilesystem JUnit Provider

A memoryfilesystem based @TempDir provider for JUnit 5.10+.
Only Path is supported, File can not be supported.
- versions 2.x are for JUnit 6 and require Java 17
- version 1.x are for Junit 5 and require Java 8
Usage
<dependency>
<groupId>com.github.marschall</groupId>
<artifactId>memoryfilesystem-junit-provider</artifactId>
<version>2.0.1</version>
<scope>test</scope>
</dependency>You can either change individual elements annoated with @TempDir to use memoryfilesystem by use of the factory annotation value.
class SomeTests {
@TempDir(factory = MemoryFileSystemTempDirFactory.class)
Path tempDirectory;
@Test
void someTest() {
Path input = Files.createFile(this.tempDirectory.resolve("input.txt"));
// test code
}
}Alternatively you can also use the @MemoryTempDir meta-annotation.
class SomeTests {
@MemoryTempDir
Path tempDirectory;
@Test
void someTest() {
Path input = Files.createFile(this.tempDirectory.resolve("input.txt"));
// test code
}
}Global Configuration
You can also make all elements annoated with @TempDir to use memoryfilesystem by use of the junit.jupiter.tempdir.factory.default configuration property.
junit.jupiter.tempdir.factory.default=com.github.marschall.memoryfilesystem.junit.MemoryFileSystemTempDirFactory