java.lang.Object | ||
↳ | org.junit.rules.ExternalResource | |
↳ | org.junit.rules.TemporaryFolder |
The TemporaryFolder Rule allows creation of files and folders that are guaranteed to be deleted when the test method finishes (whether it passes or fails):
public static class HasTempFolder { @Rule public TemporaryFolder folder= new TemporaryFolder(); @Test public void testUsingTempFolder() throws IOException { File createdFile= folder.newFile("myfile.txt"); File createdFolder= folder.newFolder("subfolder"); // ... } }
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
for testing purposes only.
| |||||||||||
Delete all files and folders under the temporary folder.
| |||||||||||
Returns a new fresh file with the given name under the temporary folder.
| |||||||||||
Returns a new fresh folder with the given name under the temporary folder.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Override to tear down your specific external resource.
| |||||||||||
Override to set up your specific external resource.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.junit.rules.ExternalResource
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.junit.rules.MethodRule
|
Delete all files and folders under the temporary folder.
Usually not called directly, since it is automatically applied
by the Rule
Returns a new fresh file with the given name under the temporary folder.
IOException |
---|
Returns a new fresh folder with the given name under the temporary folder.
Override to tear down your specific external resource.