- java.lang.Object
-
- org.junitpioneer.jupiter.resource.TemporaryDirectory
-
- All Implemented Interfaces:
org.junit.jupiter.api.extension.ExtensionContext.Store.CloseableResource,ResourceFactory<java.nio.file.Path>
public final class TemporaryDirectory extends java.lang.Object implements ResourceFactory<java.nio.file.Path>
TemporaryDirectoryis a "resource factory" implementation that, combined with@Newor@Shared, allows for the creation of temporary directories that can be used by individual tests or shared across multiple tests.When used with the
@Newannotation and the annotation'sargumentsfield is populated, the first argument will be used as the prefix of the name of the temporary directory.It is part of the "resources" JUnit Jupiter extension, which pertains to anything that needs to be injected into tests and which may need to be started up or torn down. Temporary directories are a common example.
This class is intended for users.
For more details and examples, see the documentation on resources and temporary directories.
- Since:
- 1.9.0
- See Also:
ResourceFactory,New,Shared
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classTemporaryDirectory.TemporaryDirectoryResource
-
Constructor Summary
Constructors Constructor Description TemporaryDirectory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Resource<java.nio.file.Path>create(java.util.List<java.lang.String> arguments)Returns a new resource.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.junitpioneer.jupiter.resource.ResourceFactory
close
-
-
-
-
Method Detail
-
create
public Resource<java.nio.file.Path> create(java.util.List<java.lang.String> arguments) throws java.lang.Exception
Description copied from interface:ResourceFactoryReturns a new resource.- Specified by:
createin interfaceResourceFactory<java.nio.file.Path>- Parameters:
arguments- a list of strings to be used to populate or configure the resource- Throws:
java.lang.Exception- if creating the resource failed
-
-