dotnet test "Testhost process exited with error" in CI
This message means the separate testhost process that runs your tests exited abnormally before reporting results. Causes range from a hard crash in test code (stack overflow, native AccessViolation, unhandled background-thread exception) to a transient runner hiccup that aborts the run.
What this error means
The run reports "Testhost process exited with error" and "The active test run was aborted", usually with a non-zero exit and no full results. It can be deterministic (a crashing test) or intermittent (a transient abort).
Testhost process exited with error: ... The active test run was aborted.
Reason: Test host process crashedCommon causes
A hard crash in the test process
A stack overflow, native access violation, or an unhandled exception on a background thread kills the host outright, which managed exception assertions cannot catch.
A transient runner abort
Resource pressure or an infrastructure blip aborts the run without a code-level crash.
How to fix it
Capture a dump for real crashes
- Re-run with
--blame-crashto collect a dump identifying the crashing test. - Fix the offending code (guard recursion, marshal native calls, catch background-thread exceptions).
- Re-run.
dotnet test --blame-crash --blame-hang-timeout 5mRetry genuinely transient aborts
- If no dump points to a code crash and the abort does not reproduce, treat it as transient.
- Self-healing managed runners (Latchkey) auto-retry transient testhost aborts so a one-off infrastructure hiccup does not fail the pipeline.
How to prevent it
- Run with
--blame-crashin CI so crashes leave a dump. - Cap parallelism and memory so the host is not starved.
- Run CI on self-healing managed runners that auto-retry transient aborts.