package hayashi.tools.files;
import java.io.File;
+import java.io.IOException;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.*;
import org.junit.Test;
-import junit.framework.TestCase;
+public class DeleteDirTest {
-public class DeleteDirTest extends TestCase {
-
- @Test(expected = Exception.class)
+ @Test(expected = IOException.class)
public void 指定したファイルがないとき() throws Exception {
- DeleteDir.listup(new File("testspace", "FOLDER"));
+ DeleteDir.delete(new File("testspace", "FOLDER"));
+ fail("例外が発生しない"); // 例外が発生しなければ失敗
+ }
+
+ @Test
+ public void 削除対象がファイルのとき() throws IOException {
+ File newfile = new File("testspace", "FILE");
+ newfile.createNewFile();
+ DeleteDir.delete(new File("testspace", "FILE"));
+ assertThat(newfile.exists(), is(false));
}
}