Skip to content

Commit dd6266d

Browse files
committed
Don't use the Maven "target" directory as a test fixture.
Use a JUnit @tempdir instead.
1 parent 5fd2bb3 commit dd6266d

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/test/java/org/apache/commons/io/file/TempDirectoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class TempDirectoryTest {
3535

3636
@TempDir
3737
Path tempDirPath;
38-
38+
3939
@SuppressWarnings("resource")
4040
@Test
4141
void testCreatePath() throws IOException {

src/test/java/org/apache/commons/io/file/TempFileTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,24 @@
2222

2323
import java.io.IOException;
2424
import java.nio.file.Files;
25-
import java.nio.file.Paths;
25+
import java.nio.file.Path;
2626

2727
import org.junit.jupiter.api.Test;
28+
import org.junit.jupiter.api.io.TempDir;
2829

2930
/**
3031
* Tests {@link TempFile}.
3132
*/
3233
class TempFileTest {
3334

35+
@TempDir
36+
Path tempDirPath;
37+
3438
@SuppressWarnings("resource")
3539
@Test
3640
void testCreatePath() throws IOException {
3741
final TempFile ref;
38-
try (TempFile tempDir = TempFile.create(Paths.get("target"), "prefix", ".suffix")) {
42+
try (TempFile tempDir = TempFile.create(tempDirPath, "prefix", ".suffix")) {
3943
ref = tempDir;
4044
assertTrue(Files.exists(ref.get()));
4145
}

0 commit comments

Comments
 (0)