I\'m writing a test for a method that creates a file in a directory. Here\'s what my JUnit test looks like:
@Before
public void setUp(){
objectUnderTes
This is how I usually clean up files:
@AfterClass
public static void clean() {
File dir = new File(DIR_PATH);
for (File file:dir.listFiles()) {
file.delete();
}
dir.delete();
}
Your directory must be empty in order to delete it, make sure no other test methods are creating more files there.
Ensure you are closing the FileWriter instance in a finally block.