Package org.junit.jupiter.api.io
Interface TempDirFactory
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
TempDirFactory.Standard
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
@API(status=EXPERIMENTAL,
since="5.10")
public interface TempDirFactory
extends Closeable
TempDirFactory defines the SPI for creating temporary directories
programmatically.
A temporary directory factory is typically used to gain control over the temporary directory creation, like defining the parent directory or the file system that should be used.
Concrete implementations must have a default constructor.
A TempDirFactory can be configured globally for the
entire test suite via the "junit.jupiter.tempdir.factory.default"
configuration parameter (see the User Guide for details) or locally
for a test class field or method parameter via the @TempDir
annotation.
- Since:
- 5.10
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classStandardTempDirFactoryimplementation which delegates toFiles.createTempDirectory(java.nio.file.Path, java.lang.String, java.nio.file.attribute.FileAttribute<?>...)using"junit"as the prefix. -
Method Summary
Modifier and TypeMethodDescriptiondefault voidclose()createTempDirectory(ExtensionContext context) Create a new temporary directory.
-
Method Details
-
createTempDirectory
Create a new temporary directory.Depending on the implementation, the resulting
Pathmay or may not be associated with thedefault FileSystem.- Parameters:
context- the current extension context; nevernull- Returns:
- the path to the newly created temporary directory; never
null - Throws:
Exception- in case of failures
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-