You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

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