---
description: A guide for generating Trunk-compatible test reports for Rust
---

# cargo-nextest

You can automatically [detect and manage flaky tests](../../detection) in your Rust projects by integrating with Trunk. This document explains how to configure cargo-nextest to output JUnit XML reports that can be uploaded to Trunk for analysis.

### Checklist

By the end of this guide, you should achieve the following before proceeding to the [next steps](#next-step) to configure your CI provider.

* [ ] Generate a compatible test report
* [ ] Configure the report file path or glob
* [ ] Disable retries for better detection accuracy
* [ ] Test uploads locally

After correctly generating reports following the above steps, you'll be ready to move on to the next steps to [configure uploads in CI](../ci-providers).

### Generating Reports

`cargo-nextest` has built-in reporting for JUnit XML reports, which is trunk-compatible. You can enable JUnit reporting by adding the following to your nextest config:

{% code title=".config/nextest.toml" %}
```toml
[profile.ci.junit]
path = "junit.xml"
```
{% endcode %}

You can invoke this profile when running tests with:

```sh
cargo nextest run --profile ci
```

#### Report File Path

`cargo-nextest` outputs artifacts at `target/nextest` by default. When you provide a profile and a file name via the config example above, it produces a report at `target/nextest/ci/junit.xml`.&#x20;

#### Disable Retries

You need to disable automatic retries if you previously enabled them. Retries compromise the accurate detection of flaky tests.&#x20;

Omit the `--retries` option.

### Try It Locally

#### The Validate Command

You can validate your test reports using the [Trunk CLI](../../uploader). If you don't have it installed already, you can install and run the `validate` command like this:

```sh
curl -fsSLO --retry 3 https://trunk.io/releases/trunk && chmod +x trunk
./trunk flakytests validate --junit-paths "./target/nextest/ci/junit.xml"
```

**This will not upload anything to Trunk**. To improve detection accuracy, you should **address all errors and warnings** before proceeding to the next steps.

#### Test Upload

Before modifying your CI jobs to automatically upload test results to Trunk, try uploading a single test run manually.

You make an upload to Trunk using the following command:

```sh
curl -fsSLO --retry 3 https://trunk.io/releases/trunk && chmod +x trunk
./trunk flakytests upload --junit-paths "./target/nextest/ci/junit.xml" \
    --org-url-slug <TRUNK_ORG_SLUG> \
    --token <TRUNK_ORG_TOKEN>
```

### Next Steps

Configure your CI to upload test runs to Trunk. Find the guides for your CI framework below:

<table data-view="cards" data-full-width="false"><thead><tr><th></th><th data-hidden></th><th data-hidden data-card-target data-type="content-ref"></th><th data-hidden data-card-cover data-type="files"></th></tr></thead><tbody><tr><td><strong>Azure DevOps Pipelines</strong></td><td></td><td><a href="../ci-providers/azure-devops-pipelines">azure-devops-pipelines</a></td><td><a href="https://577236045-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F61Ep9MrYBkJa0Yq3zS1s%2Fuploads%2FQ0rWUH25QyqS5GDS55lT%2Fazure.png?alt=media&#x26;token=8c1f9384-193c-4c9a-b112-f5561613f4eb">azure.png</a></td></tr><tr><td><strong>BitBucket Pipelines</strong></td><td></td><td><a href="../ci-providers/bitbucket-pipelines">bitbucket-pipelines</a></td><td><a href="https://577236045-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F61Ep9MrYBkJa0Yq3zS1s%2Fuploads%2FabnU59zhrjW2NHoPDfvi%2Fbitbucket.png?alt=media&#x26;token=57c3f77d-ec25-4379-911e-4fbc3c598307">bitbucket.png</a></td></tr><tr><td><strong>BuildKite</strong></td><td></td><td><a href="../ci-providers/buildkite">buildkite</a></td><td><a href="https://577236045-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F61Ep9MrYBkJa0Yq3zS1s%2Fuploads%2FNcUukSy7Akhwp1gY95KM%2Fbuildkite.png?alt=media&#x26;token=e9f76b00-59f8-40cd-b36b-91a5f4346425">buildkite.png</a></td></tr><tr><td><strong>CircleCI</strong></td><td></td><td><a href="../ci-providers/circleci">circleci</a></td><td><a href="https://577236045-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F61Ep9MrYBkJa0Yq3zS1s%2Fuploads%2FtNKP5xVE83n9ANPQNRui%2Fcircle-ci.png?alt=media&#x26;token=572bfc49-0f46-4da7-a5a0-b8a6532b5116">circle-ci.png</a></td></tr><tr><td><strong>Drone CI</strong></td><td></td><td><a href="../ci-providers/droneci">droneci</a></td><td><a href="https://577236045-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F61Ep9MrYBkJa0Yq3zS1s%2Fuploads%2FT5SjdSpdr0bUe7QyKEA7%2Fdrone.png?alt=media&#x26;token=bcd35586-c5d8-4101-9a7e-b14a91df74ed">drone.png</a></td></tr><tr><td><strong>GitHub Actions</strong></td><td></td><td><a href="../ci-providers/github-actions">github-actions</a></td><td><a href="https://577236045-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F61Ep9MrYBkJa0Yq3zS1s%2Fuploads%2FQ9mNmLONCxyxAPARPoo5%2Fgithub.png?alt=media&#x26;token=b5ca383b-e0d4-4a2c-84df-8e5b248089f0">github.png</a></td></tr><tr><td><strong>Gitlab</strong></td><td></td><td><a href="../ci-providers/gitlab">gitlab</a></td><td><a href="https://577236045-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F61Ep9MrYBkJa0Yq3zS1s%2Fuploads%2FxvmPC1rebwt2t3mf3eiu%2Fgitlab.png?alt=media&#x26;token=c596a5e4-5a1a-49f6-a85a-6344bc52bf17">gitlab.png</a></td></tr><tr><td><strong>Jenkins</strong></td><td></td><td><a href="../ci-providers/jenkins">jenkins</a></td><td><a href="https://577236045-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F61Ep9MrYBkJa0Yq3zS1s%2Fuploads%2FVMm9Exm5TBYCAYafWa1N%2Fjenkins.png?alt=media&#x26;token=7243f37d-9fa4-47d7-a9f8-9d871bdde7e3">jenkins.png</a></td></tr><tr><td><strong>Semaphore</strong></td><td></td><td><a href="../ci-providers/semaphoreci">semaphoreci</a></td><td><a href="https://577236045-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F61Ep9MrYBkJa0Yq3zS1s%2Fuploads%2FbdwX7ZvV4PygwxSKI9Z7%2Fsemaphore.png?alt=media&#x26;token=bc70d20a-5971-42a2-b53a-18a3bd889589">semaphore.png</a></td></tr><tr><td><strong>TeamCity</strong></td><td></td><td><a href="../ci-providers/teamcity">teamcity</a></td><td><a href="https://577236045-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F61Ep9MrYBkJa0Yq3zS1s%2Fuploads%2FMpdPtpzMnqKRiBWVNgtm%2Fteamcity.png?alt=media&#x26;token=5b095409-4374-4e70-91bf-0eff9ec3386b">teamcity.png</a></td></tr><tr><td><strong>Travis CI</strong></td><td></td><td><a href="../ci-providers/travisci">travisci</a></td><td><a href="https://577236045-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F61Ep9MrYBkJa0Yq3zS1s%2Fuploads%2FUCPJObs9AQFQELbc8OHC%2Ftravis.png?alt=media&#x26;token=cdea623e-aac9-4ec5-bf66-991e525dfe13">travis.png</a></td></tr><tr><td><strong>Other CI Providers</strong></td><td></td><td><a href="../ci-providers/otherci">otherci</a></td><td><a href="https://577236045-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F61Ep9MrYBkJa0Yq3zS1s%2Fuploads%2FzvwIJ7OxPKzabAuIFAwD%2Fother.png?alt=media&#x26;token=705898fa-ceb4-4972-88e6-9b2be5dcd002">other.png</a></td></tr></tbody></table>

