Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marschall/memoryfilesystem-junit-provider
A Memoryfilesystem based @TempDir provider for JUnit
https://github.com/marschall/memoryfilesystem-junit-provider
filesystem inmemory junit junit5 unit-testing
Last synced: about 10 hours ago
JSON representation
A Memoryfilesystem based @TempDir provider for JUnit
- Host: GitHub
- URL: https://github.com/marschall/memoryfilesystem-junit-provider
- Owner: marschall
- Created: 2023-05-14T12:41:57.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-09-06T13:09:33.000Z (2 months ago)
- Last Synced: 2024-09-06T14:38:36.850Z (2 months ago)
- Topics: filesystem, inmemory, junit, junit5, unit-testing
- Language: Java
- Homepage:
- Size: 35.2 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Memoryfilesystem JUnit Provider [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.marschall/memoryfilesystem-junit-provider/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.marschall/memoryfilesystem-junit-provider) [![Javadocs](https://www.javadoc.io/badge/com.github.marschall/memoryfilesystem-junit-provider.svg)](https://www.javadoc.io/doc/com.github.marschall/memoryfilesystem-junit-provider)
===============================A memoryfilesystem based [@TempDir](https://junit.org/junit5/docs/current/api/org.junit.jupiter.api/org/junit/jupiter/api/io/TempDir.html) provider for JUnit 5.10+.
Only `Path` is supported, `File` can not be supported.
Usage
-----```xml
com.github.marschall
memoryfilesystem-junit-provider
1.0.1
test```
You can either change individual elements annoated with `@TempDir` to use memoryfilesystem by use of the `factory` annotation value.
```java
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.
```java
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](https://junit.org/junit5/docs/current/api/org.junit.jupiter.api/org/junit/jupiter/api/io/TempDir.html#DEFAULT_FACTORY_PROPERTY_NAME) configuration property.
```properties
junit.jupiter.tempdir.factory.default=com.github.marschall.memoryfilesystem.junit.MemoryFileSystemTempDirFactory
```