A memoryfilesystem based @TempDir provider for JUnit 5.10+.
Only Path
is supported, File
can not be supported.
<dependency>
<groupId>com.github.marschall</groupId>
<artifactId>memoryfilesystem-junit-provider</artifactId>
<version>1.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
}
}
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