LogServiceTests fails intermittently when the full suite runs, and passes every time in isolation. It is not tied to any one test in the class — two different tests have failed across runs:
LogServiceTests.Log_WhenDisabled_DoesNotWriteFile — asserted the log file does not exist; it did (Expected: False, Actual: True)
LogServiceTests.DeleteLog_WhenFileAbsent_DoesNotThrow
Reproduction
Full suite, Release, repeated runs on the same build:
dotnet test QuickMail.Tests/QuickMail.Tests.csproj -c Release --no-build
Roughly 2 failures in 7 consecutive runs. --filter "FullyQualifiedName~LogServiceTests" passes 7/7 every time.
Cause
LogService writes to a single quickmail.log under the profile directory, and LogServiceTests asserts on that file's presence/absence. Other tests in the suite run in parallel and cause writes to the same path, so whether the file exists at assertion time depends on scheduling. The failures are pure cross-test interference — the assertions themselves are correct and the production code is fine.
Why now
This has presumably been latent for a while; it surfaced while verifying #367, whose added tests changed the parallel scheduling enough to make it visible. It is not caused by that branch — the failing tests are LogServiceTests' own and predate it.
Suggested fix
Isolate the tests from the shared path rather than serialising the whole suite — give LogServiceTests its own temp profile directory per test (or per class) so no other test can write the file being asserted on. Marking the class with a dedicated xUnit collection would also work but is a heavier hammer.
Worth fixing before it costs someone a spurious red CI run and an hour of confusion.
LogServiceTestsfails intermittently when the full suite runs, and passes every time in isolation. It is not tied to any one test in the class — two different tests have failed across runs:LogServiceTests.Log_WhenDisabled_DoesNotWriteFile— asserted the log file does not exist; it did (Expected: False, Actual: True)LogServiceTests.DeleteLog_WhenFileAbsent_DoesNotThrowReproduction
Full suite, Release, repeated runs on the same build:
dotnet test QuickMail.Tests/QuickMail.Tests.csproj -c Release --no-buildRoughly 2 failures in 7 consecutive runs.
--filter "FullyQualifiedName~LogServiceTests"passes 7/7 every time.Cause
LogServicewrites to a singlequickmail.logunder the profile directory, andLogServiceTestsasserts on that file's presence/absence. Other tests in the suite run in parallel and cause writes to the same path, so whether the file exists at assertion time depends on scheduling. The failures are pure cross-test interference — the assertions themselves are correct and the production code is fine.Why now
This has presumably been latent for a while; it surfaced while verifying #367, whose added tests changed the parallel scheduling enough to make it visible. It is not caused by that branch — the failing tests are
LogServiceTests' own and predate it.Suggested fix
Isolate the tests from the shared path rather than serialising the whole suite — give
LogServiceTestsits own temp profile directory per test (or per class) so no other test can write the file being asserted on. Marking the class with a dedicated xUnit collection would also work but is a heavier hammer.Worth fixing before it costs someone a spurious red CI run and an hour of confusion.