Skip to content
Latchkey

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).

dotnet
Testhost process exited with error: ... The active test run was aborted.
Reason: Test host process crashed

Common 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

  1. Re-run with --blame-crash to collect a dump identifying the crashing test.
  2. Fix the offending code (guard recursion, marshal native calls, catch background-thread exceptions).
  3. Re-run.
shell
dotnet test --blame-crash --blame-hang-timeout 5m

Retry genuinely transient aborts

  1. If no dump points to a code crash and the abort does not reproduce, treat it as transient.
  2. 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-crash in 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.

Frequently asked questions

What causes ""Testhost process exited with error""?
A stack overflow, native access violation, or an unhandled exception on a background thread kills the host outright, which managed exception assertions cannot catch.
How do I fix "Testhost process exited with error"?
Capture a dump for real crashes

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card