Common testing issues and their solutions.
Problem: Tests create real directories in ./data or ./build
Solution: Use TempDir for temporary directories
let temp_dir = TempDir::new().unwrap();
let path = temp_dir.path();See: Temp Directories
Problem: Emoji and progress messages appear in test output
Solution: Use silent verbosity in tests
let context = TestContext::new(); // Silent by default
let output = TestUserOutput::wrapped_silent();See: Clean Output
Problem: Tests using Utc::now() produce inconsistent results
Solution: Use MockClock for deterministic time
let clock = Arc::new(MockClock::new(fixed_time));See: Mock Clock
Problem: cargo cov-check reports coverage below 70%
Solution:
- Run
cargo cov-htmlto see detailed report - Identify untested code
- Add tests or verify if module is excluded from coverage requirements
See: Coverage
Problem: Can't identify which test case failed
Solution: Use rstest instead of loops in test body
#[rstest]
#[case(input1, expected1)]
#[case(input2, expected2)]
fn test_name(#[case] input: Type, #[case] expected: Type) {
// Each case runs separately
}See: Parameterized Tests