Tests should not have side effects on the test environment. Failing to delete files created on the file system can cause subsequent test runs or other tests to fail. Created files should be removed by the time the test has completed.

Example:

public class MyTest {
	@Before
	public void setUp() {
		// Prepare test environment
		_testFile = new File(path);
	}
	@After
	public void tearDown() {
		// Remove test related files
		_testFile.delete();
	}
}
  • No labels