Skip to content

Slow tests

Use --slow-timeout to flag slow tests during a run, or --durations to list the slowest tests afterward.

Flagging slow tests during a run

--slow-timeout=SECONDS flags every test that runs for longer than the given duration:

Bash
1
uv run karva test --slow-timeout=2.0
TOML
1
2
[tool.karva.profile.default.test]
slow-timeout = 2.0

The threshold accepts fractional seconds (--slow-timeout=0.5). Slow tests get a dedicated SLOW status line and are counted in the run summary.

The SLOW line is gated behind --status-level=slow (or higher); the summary slow count appears once --final-status-level=slow is set:

Bash
1
uv run karva test --slow-timeout=2.0 --status-level=slow --final-status-level=slow

Slow detection is purely informational — it does not fail the run or kill the test. To time-box a test instead, use @karva.tags.timeout. To fail a test that exceeds a duration budget without killing it mid-execution, use fail-slow.

Ranking the slowest tests

--durations=N prints the N slowest tests after the run completes, regardless of whether --slow-timeout is set:

Bash
1
uv run karva test --durations=10

No threshold is needed.