Why use cargo-nextest
Carol Zhang written April 2025
What is cargo-nextest?
cargo-nextest
is a test runner for Rust projects. It has several
improvements over
cargo test
, the default test runner than comes out of the box with the Rust toolchain. While
both work quite well, nextest's features make running tests more efficient, reliable, and plain enjoyable.
The nextest project is lead by Rain (aka sunshowers on GitHub). A lot of the source
material here comes from their blog.
I'm assuming everyone has a basic understanding of Rust and cargo so I'll jump straight to talking about what I like about nextest.
Speed
Nextest is fast. The main draw for my team is parallel execution of tests. Since we have a large codebase
with lots of tests, a short feedback loop is very important when you're trying to make sure your local
feature branch
hasn't broken anything as you try to quickly iterate through different solutions. Nextest runs each
test in a separate process, each in parallel. This also means one test failing doesn't abort the entire test
suite run like in cargo test. While adding --no-fail-fast
to cargo test does solve this issue,
the failure output
is printed when the test is run, so in a large codebase where there are a lot of tests, we may have to
scroll quite a bit to locate the failure(s).
Retries
Speaking of failures, when a test fails, nextest is able to automatically retry. If the same test
succeeds after a retry or two, it is marked as flaky. Retries can be configured via the command
line with the --retries
option, or in config/nextest.toml
.
I cannot stress how handy this is especially for tests in distributed systems, where many things can and do go wrong seemingly randomly, and it is sometimes tricky to reason about. I don't know about you but if a test in a part of a codebase I'm not very familiar with fails, the first thing I do is run it again. This is the test equivalent of "turn it off and back on again". Not only do automatic retries save time, it also points out potential flaws in the test suite, nudging devs to take another look at how a particular test is set up. In a way, this goes beyond just running tests; it's about how and why we test our system.
In addition, nextest includes fixed and exponential backoff, with jitter support for both.
Other things I like
Whenever there is a new tool to try, ease of adoption is a huge plus for me. In my experience, simply
switching from running the command cargo test
to cargo nextest
has been sufficient
to run all my tests
on the nextest runner. No refactoring and no tweaking needed. I really like how nextest doesn't force a
specific syntax or add dependencies to lock you in to the test runner.
Nextest's output format is also a lot easier to read. Look at the output of cargo test

and that of cargo nextest

Questions? Comments? Salad dressing recipe? Reach out on Twitter.