How to Supercharge Your Rust Testing with cargo-nextest
By • min read
<h2>Introduction</h2>
<p>If you've ever waited for a large Rust test suite to finish, you know the pain. Tests are essential, but slow execution can drain productivity, especially in CI pipelines or on projects with hundreds of integration tests. Enter <strong>cargo-nextest</strong>, a next-generation test runner created by <strong>Rain</strong> (a seasoned engineer from Meta, Mozilla, and Oxide Computer Company). It's designed to be faster, more observable, and more reliable than the default <code>cargo test</code> — benchmarks show it can be up to <strong>3x faster</strong> depending on the workload. And with <strong>RustRover 2026.1</strong> now offering native cargo-nextest support, running and monitoring tests directly from your IDE has never been easier. This guide will walk you through everything you need to know to start using cargo-nextest effectively.</p><figure style="margin:20px 0"><img src="https://blog.jetbrains.com/wp-content/uploads/2026/05/RR-Blog_Social_Share_Marketo_Preview_Livestream-1280x720-2x.png" alt="How to Supercharge Your Rust Testing with cargo-nextest" style="width:100%;height:auto;border-radius:8px" loading="lazy"><figcaption style="font-size:12px;color:#666;margin-top:5px">Source: blog.jetbrains.com</figcaption></figure>
<h2>What You Need</h2>
<ul>
<li>A <strong>Rust</strong> installation (including <code>cargo</code>)</li>
<li>A Rust project (preferably with existing tests)</li>
<li>(Optional) <strong>RustRover 2026.1</strong> or later for IDE integration</li>
<li>Basic familiarity with terminal commands</li>
</ul>
<h2>Step 1: Install cargo-nextest</h2>
<p id="step1">Open your terminal and run:</p>
<pre><code>cargo install cargo-nextest</code></pre>
<p>This installs the <code>cargo-nextest</code> binary globally. Once complete, verify the installation with:</p>
<pre><code>cargo nextest --version</code></pre>
<h2>Step 2: Run Your First Test Suite</h2>
<p id="step2">Navigate to your Rust project directory and execute:</p>
<pre><code>cargo nextest run</code></pre>
<p>This runs all your tests in parallel using a more efficient scheduling algorithm. You'll see a structured output with test names, statuses, and timings. Unlike <code>cargo test</code>, tests are organized by binary, and failures are clearly separated.</p>
<h2>Step 3: Understand the Output and Artifacts</h2>
<p id="step3">cargo-nextest produces detailed machine-readable output. By default, it saves results as <strong>JUnit XML</strong> in the <code>.nextest</code> directory. You can also view a summary in the terminal or use the <code>--message-format</code> flag for JSON output. This makes it easy to integrate with CI systems like Jenkins, GitLab CI, or GitHub Actions.</p>
<p>To see a human-readable list of failed tests:</p>
<pre><code>cargo nextest run --failure-output immediate</code></pre>
<h2>Step 4: Configure for CI Pipelines</h2>
<p id="step4">Speed and reliability matter most in CI. Customize your nextest run with environment variables and flags:</p>
<ul>
<li><strong>Retry flaky tests:</strong> <code>--retries 2</code> (re-runs failed tests up to 2 times)</li>
<li><strong>Filter by test name:</strong> <code>-E 'test(integration)'</code> (run only tests matching the expression)</li>
<li><strong>Partition tests across multiple CI jobs:</strong> Use <code>--partition hash:1/4</code> (first of four partitions)</li>
<li><strong>Set timeout:</strong> <code>--test-timeout 60000</code> (milliseconds)</li>
</ul>
<p>These options make cargo-nextest ideal for large monorepos with thousands of tests.</p><figure style="margin:20px 0"><img src="https://blog.jetbrains.com/wp-content/uploads/2025/12/Screenshot-2025-10-23-at-06.34.51.png" alt="How to Supercharge Your Rust Testing with cargo-nextest" style="width:100%;height:auto;border-radius:8px" loading="lazy"><figcaption style="font-size:12px;color:#666;margin-top:5px">Source: blog.jetbrains.com</figcaption></figure>
<h2>Step 5: Integrate with RustRover (Optional)</h2>
<p id="step5">If you use <strong>RustRover 2026.1</strong>, you can run cargo-nextest directly from the IDE. Open the <strong>Test tool window</strong> and select cargo-nextest as the runner. You'll see real-time progress, pass/fail counts, and structured results — the same experience you get with the terminal but embedded in your editor.</p>
<h2>Step 6: Use Advanced Features</h2>
<p id="step6">cargo-nextest offers features that shine at scale:</p>
<ul>
<li><strong>Builder strategies:</strong> Control how test binaries are built (e.g., <code>--build-config</code> for separate debug builds for tests).</li>
<li><strong>Test partitioning:</strong> Distribute tests across multiple machines or containers.</li>
<li><strong>Custom reporters:</strong> Write your own output format or send results to a dashboard.</li>
<li><strong>Sandboxing:</strong> Isolate tests to prevent side effects.</li>
</ul>
<p>Explore the full documentation with <code>cargo nextest help</code>.</p>
<h2>Tips for Success</h2>
<ul>
<li><strong>Start small:</strong> If you have a large project, begin by running cargo-nextest on a subset of tests to see the speedup before rolling out globally.</li>
<li><strong>Combine with Clippy:</strong> Use <code>cargo nextest run --cargo-quiet</code> to reduce noise; pair it with <code>cargo clippy</code> in CI.</li>
<li><strong>Benchmark your project:</strong> Compare <code>cargo test</code> vs <code>cargo nextest run</code> on warm caches — you might be surprised.</li>
<li><strong>Monitor the .nextest directory:</strong> Artifacts can accumulate; clean them periodically or exclude from version control.</li>
<li><strong>Leverage the community:</strong> Rain actively maintains cargo-nextest and is responsive on GitHub, so file issues or feature requests.</li>
</ul>
<p>By following these steps, you'll unlock faster, more observable test runs that scale from personal projects to enterprise CI. Whether you're a solo developer or part of a large team, cargo-nextest is a tool worth adding to your Rust arsenal.</p>