66import java .io .File ;
77import java .io .IOException ;
88
9+ import static org .junit .Assert .assertFalse ;
910import static org .junit .Assert .assertTrue ;
1011
1112public class CreateFilesUnitTest {
@@ -14,7 +15,8 @@ public void givenAnExistingDirectory_whenCreatingAFileWithAbsolutePath_thenFileI
1415 File tempDirectory = new File (System .getProperty ("java.io.tmpdir" ));
1516 File fileWithAbsolutePath = new File (tempDirectory .getAbsolutePath () + "/myDirectory/testFile.txt" );
1617
17- fileWithAbsolutePath .mkdirs ();
18+ assertFalse (fileWithAbsolutePath .exists ());
19+
1820 Files .touch (fileWithAbsolutePath );
1921
2022 assertTrue (fileWithAbsolutePath .exists ());
@@ -25,17 +27,20 @@ public void givenAnExistingDirectory_whenCreatingANewDirectoryAndFileWithRelativ
2527 File tempDirectory = new File (System .getProperty ("java.io.tmpdir" ));
2628 File fileWithRelativePath = new File (tempDirectory , "myDirectory/newFile.txt" );
2729
28- fileWithRelativePath .mkdirs ();
30+ assertFalse (fileWithRelativePath .exists ());
31+
2932 Files .touch (fileWithRelativePath );
3033
3134 assertTrue (fileWithRelativePath .exists ());
3235 }
3336
3437 @ Test
3538 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 ());
3743
38- newFile .mkdirs ();
3944 Files .touch (newFile );
4045
4146 assertTrue (newFile .exists ());
0 commit comments