| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 714e909 commit 42b6bf5
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,7 @@ | |||
| 6 | 6 | import java.io.File; | |
| 7 | 7 | import java.io.IOException; | |
| 8 | 8 | ||
| 9 | + import static org.junit.Assert.assertFalse; | ||
| 9 | 10 | import static org.junit.Assert.assertTrue; | |
| 10 | 11 | ||
| 11 | 12 | public class CreateFilesUnitTest { | |
@@ -14,7 +15,8 @@ public void givenAnExistingDirectory_whenCreatingAFileWithAbsolutePath_thenFileI | |||
| 14 | 15 | File tempDirectory = new File(System.getProperty("java.io.tmpdir")); | |
| 15 | 16 | File fileWithAbsolutePath = new File(tempDirectory.getAbsolutePath() + "/myDirectory/testFile.txt"); | |
| 16 | 17 | ||
| 17 | - fileWithAbsolutePath.mkdirs(); | ||
| 18 | + assertFalse(fileWithAbsolutePath.exists()); | ||
| 19 | + | ||
| 18 | 20 | Files.touch(fileWithAbsolutePath); | |
| 19 | 21 | ||
| 20 | 22 | assertTrue(fileWithAbsolutePath.exists()); | |
@@ -25,17 +27,20 @@ public void givenAnExistingDirectory_whenCreatingANewDirectoryAndFileWithRelativ | |||
| 25 | 27 | File tempDirectory = new File(System.getProperty("java.io.tmpdir")); | |
| 26 | 28 | File fileWithRelativePath = new File(tempDirectory, "myDirectory/newFile.txt"); | |
| 27 | 29 | ||
| 28 | - fileWithRelativePath.mkdirs(); | ||
| 30 | + assertFalse(fileWithRelativePath.exists()); | ||
| 31 | + | ||
| 29 | 32 | Files.touch(fileWithRelativePath); | |
| 30 | 33 | ||
| 31 | 34 | assertTrue(fileWithRelativePath.exists()); | |
| 32 | 35 | } | |
| 33 | 36 | ||
| 34 | 37 | @Test | |
| 35 | 38 | public void whenCreatingAFileWithFileSeparator_thenFileIsCreated() throws IOException { | |
| 36 | - File newFile = new File("src" + File.separator + "test" + File.separator + "resources" + File.separator + "newFile.txt"); | ||
| 39 | + File tempDirectory = new File(System.getProperty("java.io.tmpdir")); | ||
| 40 | + File newFile = new File(tempDirectory.getAbsolutePath() + File.separator + "newFile.txt"); | ||
| 41 | + | ||
| 42 | + assertFalse(newFile.exists()); | ||
| 37 | 43 | ||
| 38 | - newFile.mkdirs(); | ||
| 39 | 44 | Files.touch(newFile); | |
| 40 | 45 | ||
| 41 | 46 | assertTrue(newFile.exists()); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments