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.
Implementations must provide a no-args constructor and should not make any
assumptions regarding when and how many times they are instantiated, but they
can assume that createTempDirectory(AnnotatedElementContext, ExtensionContext)
and close() will both be called once per instance, in this order,
and from the same thread.
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.
@TempDir
| Modifier and Type | Class and Description |
|---|---|
| public static class | TempDirFactory.
Standard |
| Modifier and Type | Method and Description |
|---|---|
| public default void | close()
Implements java. Closes this stream and releases any system resources associated with it. |
| public Path | Returns: the path to the newly created temporary directory; nevernullthe context of the field or parameter where
elementContext, ExtensionContext @TempDir is declared; never nullthe current extension context; never extensionContext)nullCreate a new temporary directory. |
| close | back to summary |
|---|---|
| public default void close() throws IOException Implements java. Doc from java. Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect. As noted in
| |
| createTempDirectory | back to summary |
|---|---|
| public Path createTempDirectory(AnnotatedElementContext elementContext, ExtensionContext extensionContext) throws Exception Create a new temporary directory. Depending on the implementation, the resulting
| |
TempDirFactory implementation which delegates to
Files#createTempDirectory using "junit-" as prefix.
The created temporary directory is always created in the default file system with the system's default temporary directory as its parent.
| Modifier and Type | Field and Description |
|---|---|
| public static final TempDirFactory | |
| private static final String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Path | createTempDirectory(AnnotatedElementContext elementContext, ExtensionContext extensionContext)
Implements org. Create a new temporary directory. |
| INSTANCE | back to summary |
|---|---|
| public static final TempDirFactory INSTANCE | |
| TEMP_DIR_PREFIX | back to summary |
|---|---|
| private static final String TEMP_DIR_PREFIX | |
| Standard | back to summary |
|---|---|
| public Standard() | |
| createTempDirectory | back to summary |
|---|---|
| public Path createTempDirectory(AnnotatedElementContext elementContext, ExtensionContext extensionContext) throws IOException Implements org. Doc from org. Create a new temporary directory. Depending on the implementation, the resulting
| |