-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Description
Standardize temporary file creation, cleanup, and path management across all tests to prevent test artifacts and improve reliability.
Phase
Phase 0: Test Technical Debt Cleanup
Epic
Related to #202
Acceptance Criteria
- Audit all tests that create temporary files or directories
- Create standardized
TestFileManagerutility - Ensure all temporary files are cleaned up in TearDown methods
- Use unique paths to prevent test interference
- Add failure cleanup for interrupted tests
Current Issues
- Some tests use hardcoded temporary paths
- Inconsistent cleanup of failed test artifacts
- Potential file conflicts between parallel tests
Proposed Solution
public class TestFileManager : IDisposable
{
private readonly List<string> _tempPaths = new();
public string CreateTempDirectory(string prefix = "test")
{
var path = Path.Combine(Path.GetTempPath(), $"{prefix}_{Guid.NewGuid():N}");
Directory.CreateDirectory(path);
_tempPaths.Add(path);
return path;
}
public string CreateTempFile(string extension = ".tmp")
{
var path = Path.Combine(Path.GetTempPath(), $"test_{Guid.NewGuid():N}{extension}");
_tempPaths.Add(path);
return path;
}
public void Dispose()
{
foreach (var path in _tempPaths)
{
try
{
if (Directory.Exists(path))
Directory.Delete(path, true);
else if (File.Exists(path))
File.Delete(path);
}
catch { /* Ignore cleanup failures */ }
}
}
}Files to Review
- Search for
Path.GetTempPath()usage - Tests creating database files
- Serialization tests
- Integration tests with file I/O