Running tests¶
To build and run all tests in a workspace1, cd into the workspace and run:
cargo nextest run
This will produce output that looks like:
------------
Nextest run ID 1f79aa0d-4ec8-4a5c-aa83-5e8dc2f36573 with nextest profile: default
Starting 14 tests across 3 binaries (177 tests skipped)
PASS [ 0.005s] nextest-runner reporter::tests::no_capture_settings
PASS [ 0.004s] nextest-runner reporter::tests::test_final_warnings
PASS [ 0.004s] nextest-runner reporter::tests::test_progress_bar_prefix
PASS [ 0.010s] nextest-runner reporter::tests::on_test_finished_store_final_3
PASS [ 0.011s] nextest-runner reporter::tests::on_test_finished_store_final_2
PASS [ 0.011s] nextest-runner reporter::tests::on_test_finished_store_final_1
PASS [ 0.011s] nextest-runner reporter::tests::on_test_finished_with_interrupt
PASS [ 0.013s] nextest-runner reporter::tests::on_test_finished_dont_show_immediate
PASS [ 0.013s] nextest-runner reporter::tests::on_test_finished_show_immediate
PASS [ 0.012s] nextest-runner reporter::tests::on_test_finished_write_status_line
PASS [ 0.014s] nextest-runner reporter::tests::on_test_finished_dont_store_final
PASS [ 0.014s] nextest-runner reporter::tests::test_write_skip_counts
PASS [ 0.018s] nextest-runner reporter::tests::on_test_finished_dont_write_status_line
PASS [ 0.019s] nextest-runner reporter::tests::on_test_finished_store_final_4
------------
Summary [ 0.021s] 14 tests run: 14 passed, 177 skipped
------------
Nextest run ID 1f79aa0d-4ec8-4a5c-aa83-5e8dc2f36573 with nextest profile: default
Starting 14 tests across 3 binaries (177 tests skipped)
PASS [ 0.005s] nextest-runner reporter::tests::no_capture_settings
PASS [ 0.004s] nextest-runner reporter::tests::test_final_warnings
PASS [ 0.004s] nextest-runner reporter::tests::test_progress_bar_prefix
PASS [ 0.010s] nextest-runner reporter::tests::on_test_finished_store_final_3
PASS [ 0.011s] nextest-runner reporter::tests::on_test_finished_store_final_2
PASS [ 0.011s] nextest-runner reporter::tests::on_test_finished_store_final_1
PASS [ 0.011s] nextest-runner reporter::tests::on_test_finished_with_interrupt
PASS [ 0.013s] nextest-runner reporter::tests::on_test_finished_dont_show_immediate
PASS [ 0.013s] nextest-runner reporter::tests::on_test_finished_show_immediate
PASS [ 0.012s] nextest-runner reporter::tests::on_test_finished_write_status_line
PASS [ 0.014s] nextest-runner reporter::tests::on_test_finished_dont_store_final
PASS [ 0.014s] nextest-runner reporter::tests::test_write_skip_counts
PASS [ 0.018s] nextest-runner reporter::tests::on_test_finished_dont_write_status_line
PASS [ 0.019s] nextest-runner reporter::tests::on_test_finished_store_final_4
------------
Summary [ 0.021s] 14 tests run: 14 passed, 177 skipped
In nextest's run output:
- Tests are marked
PASS
orFAIL
, and the amount of wall-clock time each test takes is listed within square brackets. - Tests that take more than a specified amount of time (60 seconds by default) are marked SLOW. See Slow tests and timeouts.
- The part of the test in magenta is the binary ID for a unit test binary (see Binary IDs below).
- The part after the binary ID is the test name, including the module the test is in. The final part of the test name is highlighted in bold blue text.
cargo nextest run
supports all the options that cargo test
does. For example, to only execute tests for a package called my-package
:
cargo nextest run -p my-package
For a full list of options accepted by cargo nextest run
, see Options and arguments below, or cargo nextest run --help
.
Binary IDs¶
A test binary can be any of:
- A unit test binary built from tests within
lib.rs
or its submodules. The binary ID for these are shown by nextest as just the crate name, without a::
separator inside them. - An integration test binary built from tests in the
[[test]]
section ofCargo.toml
(typically tests in thetests
directory.) The binary ID for these is has the formatcrate-name::bin-name
. - Some other kind of test binary, such as a benchmark. In this case, the binary ID is
crate-name::kind/bin-name
. For example,nextest-runner::bench/my-bench
orquick-junit::example/show-junit
.
For more about unit and integration tests, see the documentation for cargo test
.
Filtering tests¶
To only run tests that match certain names:
cargo nextest run <test-name1> <test-name2>...
Filtersets¶
Tests can also be selected using the filterset DSL. See that page for more information.
For example, to run all tests except those in the very-slow-tests
crate:
cargo nextest run -E 'not package(very-slow-tests)'
Running a subset of tests by default¶
By default, all discovered, non-ignored tests are run. To only run some tests by default, set the
default-filter
configuration.
For example, some tests might need access to special resources not available to developer
workstations. To not run tests in the special-tests
crate by default, but to run them with the
ci
profile:
.config/nextest.toml
[profile.default]
default-filter = 'not package(special-tests)'
[profile.ci]
default-filter = 'all()'
The default filter is available in the filterset DSL via the default()
predicate.
Overriding the default filter
By default, command-line arguments are always interpreted with respect to the default filter. For example, cargo nextest -E 'all()'
will run all tests that match the default filter.
To override the default filter on the command line, use --ignore-default-filter
. For example, cargo nextest -E 'all()' --ignore-default-filter
will run all tests, including those not in the default filter.
Because skipping some tests can be surprising, nextest prints the number of tests and binaries skipped due to their presence in the default filter. For example:
------------
Nextest run ID a7a1750d-895c-47a9-a72c-bd1e0bce6d19 with nextest profile: default
Starting 233 tests across 10 binaries (14 tests and 2 binaries skipped via profile.default.default-filter)
PASS [ 0.007s] nextest-filtering parsing::tests::test_complex_error
PASS [ 0.007s] nextest-filtering parsing::tests::test_expected_eof
PASS [ 0.007s] nextest-filtering parsing::tests::test_expected_expr
...
------------
Nextest run ID a7a1750d-895c-47a9-a72c-bd1e0bce6d19 with nextest profile: default
Starting 233 tests across 10 binaries (14 tests and 2 binaries skipped via profile.default.default-filter)
PASS [ 0.007s] nextest-filtering parsing::tests::test_complex_error
PASS [ 0.007s] nextest-filtering parsing::tests::test_expected_eof
PASS [ 0.007s] nextest-filtering parsing::tests::test_expected_expr
...
Default filter vs ignored tests
The default filter and #[ignore]
can both be used to filter out some tests by default. However, there are key distinctions between the two:
- The default filter is defined in nextest's configuration while ignored tests are annotated within Rust code.
- Default filters can be separately configured per-profile. Ignored tests are global to the repository.
- Default filters are a nextest feature, while ignored tests also work with
cargo test
.
In practice, #[ignore]
is often used for failing tests, while the default filter is typically used to filter out tests that are very slow or require specific resources.
Per-platform default filters¶
Default filters can be set per-platform via the overrides
section.
[[profile.default.overrides]]
platform = 'cfg(windows)'
default-filter = 'not test()'
--skip
and --exact
¶
Nextest accepts the --skip
and --exact
arguments after --
, emulating the corresponding
arguments accepted by cargo test
. The --skip
and --exact
arguments apply to test name filters
passed in after --
.
For example, to run all tests matching the substring test3
, but not including skip1
or skip2
:
cargo nextest run -- --skip skip1 --skip skip2 test3
To run all tests matching exactly the names test1
and test2
:
cargo nextest run -- test1 test2 --exact
To run all tests except those matching exactly slow_module::my_test
:
cargo nextest run -- --exact --skip slow_module::my_test
Alternatively, and in prior versions of nextest, use a filterset. Some examples:
cargo test command |
Nextest filterset command |
---|---|
cargo test -- --skip skip1 --skip skip2 test3 |
cargo nextest run -E 'test(test3) - test(/skip[12]/)' |
cargo test -- test1 test2 --exact |
cargo nextest run -E 'test(=test1) + test(=test2)' |
cargo test -- --exact --skip slow_module::my_test |
cargo nextest run -E 'not test(=slow_module::my_test) |
Filtering by build platform¶
While cross-compiling code, some tests (e.g. proc-macro tests) may need to be run on the host platform. To filter tests based on the build platform they're for, nextest's filtersets accept the platform()
set with values target
and host
.
For example, to only run tests for the host platform:
cargo nextest run -E 'platform(host)'
Other runner options¶
--no-fail-fast
- Do not exit the test run on the first failure. Most useful for CI scenarios.
-j
,--test-threads
- Number of tests to run simultaneously. Note that this is separate from the number of build jobs to run simultaneously, which is specified by
--build-jobs
. --run-ignored only
0.9.76- Run only ignored tests. (With prior nextest versions, use
--run-ignored ignored-only
.) --run-ignored all
- Run both ignored and non-ignored tests.
Controlling nextest's output¶
For information about configuring the way nextest displays its human-readable output, see Reporting test results.
Options and arguments¶
The output of cargo nextest run -h
:
Build and run tests
Usage: cargo nextest run [OPTIONS] [FILTERS]... [-- <FILTERS_AND_ARGS>...]
Arguments:
[FILTERS]... Test name filters
[FILTERS_AND_ARGS]... Test name filters and emulated test binary arguments
Options:
-v, --verbose Verbose output [env: NEXTEST_VERBOSE=]
--color <WHEN> Produce color output: auto, always, never [env: CARGO_TERM_COLOR=always]
[default: auto]
-h, --help Print help (see more with '--help')
Package selection:
-p, --package <PACKAGES> Package to test
--workspace Test all packages in the workspace
--exclude <EXCLUDE> Exclude packages from the test
--all Alias for --workspace (deprecated)
Target selection:
--lib Test only this package's library unit tests
--bin <BIN> Test only the specified binary
--bins Test all binaries
--example <EXAMPLE> Test only the specified example
--examples Test all examples
--test <TEST> Test only the specified test target
--tests Test all targets
--bench <BENCH> Test only the specified bench target
--benches Test all benches
--all-targets Test all targets
Feature selection:
-F, --features <FEATURES> Space or comma separated list of features to activate
--all-features Activate all available features
--no-default-features Do not activate the `default` feature
Compilation options:
--build-jobs <N> Number of build jobs to run
-r, --release Build artifacts in release mode, with optimizations
--cargo-profile <NAME> Build artifacts with the specified Cargo profile
--target <TRIPLE> Build for the target triple
--target-dir <DIR> Directory for all generated artifacts
--unit-graph Output build graph in JSON (unstable)
--timings[=<FMTS>] Timing output formats (unstable) (comma separated): html, json
Manifest options:
--manifest-path <PATH> Path to Cargo.toml
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
--offline Run without accessing the network
Other Cargo options:
--cargo-quiet... Do not print cargo log messages (specify twice for no Cargo output
at all)
--cargo-verbose... Use cargo verbose output (specify twice for very verbose/build.rs
output)
--ignore-rust-version Ignore `rust-version` specification in packages
--future-incompat-report Outputs a future incompatibility report at the end of the build
--config <KEY=VALUE> Override a configuration value
-Z <FLAG> Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for
details
Filter options:
--run-ignored <WHICH> Run ignored tests [possible values: default, only, all]
--partition <PARTITION> Test partition, e.g. hash:1/2 or count:2/3
-E, --filterset <EXPR> Test filterset (see
<https://nexte.st/docs/filtersets>)
--ignore-default-filter Ignore the default filter configured in the profile
Runner options:
--no-run Compile, but don't run tests
-j, --test-threads <N> Number of tests to run simultaneously [possible values: integer or
"num-cpus"] [default: from profile] [env: NEXTEST_TEST_THREADS=]
[aliases: jobs]
--retries <N> Number of retries for failing tests [default: from profile] [env:
NEXTEST_RETRIES=]
--fail-fast Cancel test run on the first failure
--no-fail-fast Run all tests regardless of failure
--no-tests=<ACTION> Behavior if there are no tests to run [env: NEXTEST_NO_TESTS=] [possible
values: pass, warn, fail]
--no-capture Run tests serially and do not capture output
Reporter options:
--failure-output <WHEN>
Output stdout and stderr on failure [env: NEXTEST_FAILURE_OUTPUT=] [possible values:
immediate, immediate-final, final, never]
--success-output <WHEN>
Output stdout and stderr on success [env: NEXTEST_SUCCESS_OUTPUT=] [possible values:
immediate, immediate-final, final, never]
--status-level <LEVEL>
Test statuses to output [env: NEXTEST_STATUS_LEVEL=] [possible values: none, fail, retry,
slow, leak, pass, skip, all]
--final-status-level <LEVEL>
Test statuses to output at the end of the run [env: NEXTEST_FINAL_STATUS_LEVEL=] [possible
values: none, fail, flaky, slow, skip, pass, all]
--hide-progress-bar
Do not display the progress bar [env: NEXTEST_HIDE_PROGRESS_BAR=]
--message-format <FORMAT>
Format to use for test results (experimental) [env: NEXTEST_MESSAGE_FORMAT=] [default:
human] [possible values: human, libtest-json, libtest-json-plus]
--message-format-version <VERSION>
Version of structured message-format to use (experimental) [env:
NEXTEST_MESSAGE_FORMAT_VERSION=]
Reuse build options:
--archive-file <PATH> Path to nextest archive
--archive-format <FORMAT> Archive format [default: auto] [possible values: auto, tar-zst]
--extract-to <DIR> Destination directory to extract archive to [default: temporary
directory]
--extract-overwrite Overwrite files in destination directory while extracting archive
--persist-extract-tempdir Persist extracted temporary directory
--cargo-metadata <PATH> Path to cargo metadata JSON
--workspace-remap <PATH> Remapping for the workspace root
--binaries-metadata <PATH> Path to binaries-metadata JSON
--target-dir-remap <PATH> Remapping for the target directory
Config options:
--config-file <PATH>
Config file [default: workspace-root/.config/nextest.toml]
--tool-config-file <TOOL:ABS_PATH>
Tool-specific config files
--override-version-check
Override checks for the minimum version defined in nextest's config
-P, --profile <PROFILE>
The nextest profile to use [env: NEXTEST_PROFILE=]
Build and run tests
Usage: cargo nextest run [OPTIONS] [FILTERS]... [-- <FILTERS_AND_ARGS>...]
Arguments:
[FILTERS]... Test name filters
[FILTERS_AND_ARGS]... Test name filters and emulated test binary arguments
Options:
-v, --verbose Verbose output [env: NEXTEST_VERBOSE=]
--color <WHEN> Produce color output: auto, always, never [env: CARGO_TERM_COLOR=always]
[default: auto]
-h, --help Print help (see more with '--help')
Package selection:
-p, --package <PACKAGES> Package to test
--workspace Test all packages in the workspace
--exclude <EXCLUDE> Exclude packages from the test
--all Alias for --workspace (deprecated)
Target selection:
--lib Test only this package's library unit tests
--bin <BIN> Test only the specified binary
--bins Test all binaries
--example <EXAMPLE> Test only the specified example
--examples Test all examples
--test <TEST> Test only the specified test target
--tests Test all targets
--bench <BENCH> Test only the specified bench target
--benches Test all benches
--all-targets Test all targets
Feature selection:
-F, --features <FEATURES> Space or comma separated list of features to activate
--all-features Activate all available features
--no-default-features Do not activate the `default` feature
Compilation options:
--build-jobs <N> Number of build jobs to run
-r, --release Build artifacts in release mode, with optimizations
--cargo-profile <NAME> Build artifacts with the specified Cargo profile
--target <TRIPLE> Build for the target triple
--target-dir <DIR> Directory for all generated artifacts
--unit-graph Output build graph in JSON (unstable)
--timings[=<FMTS>] Timing output formats (unstable) (comma separated): html, json
Manifest options:
--manifest-path <PATH> Path to Cargo.toml
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
--offline Run without accessing the network
Other Cargo options:
--cargo-quiet... Do not print cargo log messages (specify twice for no Cargo output
at all)
--cargo-verbose... Use cargo verbose output (specify twice for very verbose/build.rs
output)
--ignore-rust-version Ignore `rust-version` specification in packages
--future-incompat-report Outputs a future incompatibility report at the end of the build
--config <KEY=VALUE> Override a configuration value
-Z <FLAG> Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for
details
Filter options:
--run-ignored <WHICH> Run ignored tests [possible values: default, only, all]
--partition <PARTITION> Test partition, e.g. hash:1/2 or count:2/3
-E, --filterset <EXPR> Test filterset (see
<https://nexte.st/docs/filtersets>)
--ignore-default-filter Ignore the default filter configured in the profile
Runner options:
--no-run Compile, but don't run tests
-j, --test-threads <N> Number of tests to run simultaneously [possible values: integer or
"num-cpus"] [default: from profile] [env: NEXTEST_TEST_THREADS=]
[aliases: jobs]
--retries <N> Number of retries for failing tests [default: from profile] [env:
NEXTEST_RETRIES=]
--fail-fast Cancel test run on the first failure
--no-fail-fast Run all tests regardless of failure
--no-tests=<ACTION> Behavior if there are no tests to run [env: NEXTEST_NO_TESTS=] [possible
values: pass, warn, fail]
--no-capture Run tests serially and do not capture output
Reporter options:
--failure-output <WHEN>
Output stdout and stderr on failure [env: NEXTEST_FAILURE_OUTPUT=] [possible values:
immediate, immediate-final, final, never]
--success-output <WHEN>
Output stdout and stderr on success [env: NEXTEST_SUCCESS_OUTPUT=] [possible values:
immediate, immediate-final, final, never]
--status-level <LEVEL>
Test statuses to output [env: NEXTEST_STATUS_LEVEL=] [possible values: none, fail, retry,
slow, leak, pass, skip, all]
--final-status-level <LEVEL>
Test statuses to output at the end of the run [env: NEXTEST_FINAL_STATUS_LEVEL=] [possible
values: none, fail, flaky, slow, skip, pass, all]
--hide-progress-bar
Do not display the progress bar [env: NEXTEST_HIDE_PROGRESS_BAR=]
--message-format <FORMAT>
Format to use for test results (experimental) [env: NEXTEST_MESSAGE_FORMAT=] [default:
human] [possible values: human, libtest-json, libtest-json-plus]
--message-format-version <VERSION>
Version of structured message-format to use (experimental) [env:
NEXTEST_MESSAGE_FORMAT_VERSION=]
Reuse build options:
--archive-file <PATH> Path to nextest archive
--archive-format <FORMAT> Archive format [default: auto] [possible values: auto, tar-zst]
--extract-to <DIR> Destination directory to extract archive to [default: temporary
directory]
--extract-overwrite Overwrite files in destination directory while extracting archive
--persist-extract-tempdir Persist extracted temporary directory
--cargo-metadata <PATH> Path to cargo metadata JSON
--workspace-remap <PATH> Remapping for the workspace root
--binaries-metadata <PATH> Path to binaries-metadata JSON
--target-dir-remap <PATH> Remapping for the target directory
Config options:
--config-file <PATH>
Config file [default: workspace-root/.config/nextest.toml]
--tool-config-file <TOOL:ABS_PATH>
Tool-specific config files
--override-version-check
Override checks for the minimum version defined in nextest's config
-P, --profile <PROFILE>
The nextest profile to use [env: NEXTEST_PROFILE=]
The output of cargo nextest run --help
:
Build and run tests
This command builds test binaries and queries them for the tests they contain, then runs each test
in parallel.
For more information, see <https://nexte.st/docs/running>.
Usage: cargo nextest run [OPTIONS] [FILTERS]... [-- <FILTERS_AND_ARGS>...]
Arguments:
[FILTERS]...
Test name filters
[FILTERS_AND_ARGS]...
Test name filters and emulated test binary arguments.
Supported arguments:
- --ignored: Only run ignored tests
- --include-ignored: Run both ignored and non-ignored tests
- --skip PATTERN: Skip tests that match the pattern
- --exact: Run tests that exactly match patterns after `--`
Options:
-v, --verbose
Verbose output
[env: NEXTEST_VERBOSE=]
--color <WHEN>
Produce color output: auto, always, never
[env: CARGO_TERM_COLOR=always]
[default: auto]
-h, --help
Print help (see a summary with '-h')
Package selection:
-p, --package <PACKAGES>
Package to test
--workspace
Test all packages in the workspace
--exclude <EXCLUDE>
Exclude packages from the test
--all
Alias for --workspace (deprecated)
Target selection:
--lib
Test only this package's library unit tests
--bin <BIN>
Test only the specified binary
--bins
Test all binaries
--example <EXAMPLE>
Test only the specified example
--examples
Test all examples
--test <TEST>
Test only the specified test target
--tests
Test all targets
--bench <BENCH>
Test only the specified bench target
--benches
Test all benches
--all-targets
Test all targets
Feature selection:
-F, --features <FEATURES>
Space or comma separated list of features to activate
--all-features
Activate all available features
--no-default-features
Do not activate the `default` feature
Compilation options:
--build-jobs <N>
Number of build jobs to run
-r, --release
Build artifacts in release mode, with optimizations
--cargo-profile <NAME>
Build artifacts with the specified Cargo profile
--target <TRIPLE>
Build for the target triple
--target-dir <DIR>
Directory for all generated artifacts
--unit-graph
Output build graph in JSON (unstable)
--timings[=<FMTS>]
Timing output formats (unstable) (comma separated): html, json
Manifest options:
--manifest-path <PATH>
Path to Cargo.toml
--frozen
Require Cargo.lock and cache are up to date
--locked
Require Cargo.lock is up to date
--offline
Run without accessing the network
Other Cargo options:
--cargo-quiet...
Do not print cargo log messages (specify twice for no Cargo output at all)
--cargo-verbose...
Use cargo verbose output (specify twice for very verbose/build.rs output)
--ignore-rust-version
Ignore `rust-version` specification in packages
--future-incompat-report
Outputs a future incompatibility report at the end of the build
--config <KEY=VALUE>
Override a configuration value
-Z <FLAG>
Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
Filter options:
--run-ignored <WHICH>
Run ignored tests
Possible values:
- default: Run non-ignored tests
- only: Run ignored tests
- all: Run both ignored and non-ignored tests
--partition <PARTITION>
Test partition, e.g. hash:1/2 or count:2/3
--platform-filter <PLATFORM>
Filter test binaries by build platform (DEPRECATED)
Instead, use -E with 'platform(host)' or 'platform(target)'.
[default: any]
[possible values: target, host, any]
-E, --filterset <EXPR>
Test filterset (see
<https://nexte.st/docs/filtersets>)
--ignore-default-filter
Ignore the default filter configured in the profile.
By default, all filtersets are intersected with the default filter configured in the
profile. This flag disables that behavior.
This flag doesn't change the definition of the `default()` filterset.
Runner options:
--no-run
Compile, but don't run tests
-j, --test-threads <N>
Number of tests to run simultaneously [possible values: integer or "num-cpus"] [default:
from profile]
[env: NEXTEST_TEST_THREADS=]
[aliases: jobs]
--retries <N>
Number of retries for failing tests [default: from profile]
[env: NEXTEST_RETRIES=]
--fail-fast
Cancel test run on the first failure
--no-fail-fast
Run all tests regardless of failure
--no-tests=<ACTION>
Behavior if there are no tests to run.
The default is currently `warn`, but it will change to `fail` in the future.
[env: NEXTEST_NO_TESTS=]
Possible values:
- pass: Silently exit with code 0
- warn: Produce a warning and exit with code 0
- fail: Produce an error message and exit with code 4
--no-capture
Run tests serially and do not capture output
Reporter options:
--failure-output <WHEN>
Output stdout and stderr on failure
[env: NEXTEST_FAILURE_OUTPUT=]
[possible values: immediate, immediate-final, final, never]
--success-output <WHEN>
Output stdout and stderr on success
[env: NEXTEST_SUCCESS_OUTPUT=]
[possible values: immediate, immediate-final, final, never]
--status-level <LEVEL>
Test statuses to output
[env: NEXTEST_STATUS_LEVEL=]
[possible values: none, fail, retry, slow, leak, pass, skip, all]
--final-status-level <LEVEL>
Test statuses to output at the end of the run
[env: NEXTEST_FINAL_STATUS_LEVEL=]
[possible values: none, fail, flaky, slow, skip, pass, all]
--hide-progress-bar
Do not display the progress bar
[env: NEXTEST_HIDE_PROGRESS_BAR=]
--message-format <FORMAT>
Format to use for test results (experimental)
[env: NEXTEST_MESSAGE_FORMAT=]
[default: human]
Possible values:
- human: The default output format
- libtest-json: Output test information in the same format as libtest
- libtest-json-plus: Output test information in the same format as libtest, with a
`nextest` subobject that includes additional metadata
--message-format-version <VERSION>
Version of structured message-format to use (experimental).
This allows the machine-readable formats to use a stable structure for consistent
consumption across changes to nextest. If not specified, the latest version is used.
[env: NEXTEST_MESSAGE_FORMAT_VERSION=]
Reuse build options:
--archive-file <PATH>
Path to nextest archive
--archive-format <FORMAT>
Archive format
[default: auto]
[possible values: auto, tar-zst]
--extract-to <DIR>
Destination directory to extract archive to [default: temporary directory]
--extract-overwrite
Overwrite files in destination directory while extracting archive
--persist-extract-tempdir
Persist extracted temporary directory
--cargo-metadata <PATH>
Path to cargo metadata JSON
--workspace-remap <PATH>
Remapping for the workspace root
--binaries-metadata <PATH>
Path to binaries-metadata JSON
--target-dir-remap <PATH>
Remapping for the target directory
Config options:
--config-file <PATH>
Config file [default: workspace-root/.config/nextest.toml]
--tool-config-file <TOOL:ABS_PATH>
Tool-specific config files
Some tools on top of nextest may want to set up their own default configuration but
prioritize user configuration on top. Use this argument to insert configuration that's
lower than --config-file in priority but above the default config shipped with nextest.
Arguments are specified in the format "tool:abs_path", for example
"my-tool:/path/to/nextest.toml" (or "my-tool:C:\\path\\to\\nextest.toml" on Windows).
Paths must be absolute.
This argument may be specified multiple times. Files that come later are lower priority
than those that come earlier.
--override-version-check
Override checks for the minimum version defined in nextest's config.
Repository and tool-specific configuration files can specify minimum required and
recommended versions of nextest. This option overrides those checks.
-P, --profile <PROFILE>
The nextest profile to use.
Nextest's configuration supports multiple profiles, which can be used to set up different
configurations for different purposes. (For example, a configuration for local runs and
one for CI.) This option selects the profile to use.
[env: NEXTEST_PROFILE=]
Build and run tests
This command builds test binaries and queries them for the tests they contain, then runs each test
in parallel.
For more information, see <https://nexte.st/docs/running>.
Usage: cargo nextest run [OPTIONS] [FILTERS]... [-- <FILTERS_AND_ARGS>...]
Arguments:
[FILTERS]...
Test name filters
[FILTERS_AND_ARGS]...
Test name filters and emulated test binary arguments.
Supported arguments:
- --ignored: Only run ignored tests
- --include-ignored: Run both ignored and non-ignored tests
- --skip PATTERN: Skip tests that match the pattern
- --exact: Run tests that exactly match patterns after `--`
Options:
-v, --verbose
Verbose output
[env: NEXTEST_VERBOSE=]
--color <WHEN>
Produce color output: auto, always, never
[env: CARGO_TERM_COLOR=always]
[default: auto]
-h, --help
Print help (see a summary with '-h')
Package selection:
-p, --package <PACKAGES>
Package to test
--workspace
Test all packages in the workspace
--exclude <EXCLUDE>
Exclude packages from the test
--all
Alias for --workspace (deprecated)
Target selection:
--lib
Test only this package's library unit tests
--bin <BIN>
Test only the specified binary
--bins
Test all binaries
--example <EXAMPLE>
Test only the specified example
--examples
Test all examples
--test <TEST>
Test only the specified test target
--tests
Test all targets
--bench <BENCH>
Test only the specified bench target
--benches
Test all benches
--all-targets
Test all targets
Feature selection:
-F, --features <FEATURES>
Space or comma separated list of features to activate
--all-features
Activate all available features
--no-default-features
Do not activate the `default` feature
Compilation options:
--build-jobs <N>
Number of build jobs to run
-r, --release
Build artifacts in release mode, with optimizations
--cargo-profile <NAME>
Build artifacts with the specified Cargo profile
--target <TRIPLE>
Build for the target triple
--target-dir <DIR>
Directory for all generated artifacts
--unit-graph
Output build graph in JSON (unstable)
--timings[=<FMTS>]
Timing output formats (unstable) (comma separated): html, json
Manifest options:
--manifest-path <PATH>
Path to Cargo.toml
--frozen
Require Cargo.lock and cache are up to date
--locked
Require Cargo.lock is up to date
--offline
Run without accessing the network
Other Cargo options:
--cargo-quiet...
Do not print cargo log messages (specify twice for no Cargo output at all)
--cargo-verbose...
Use cargo verbose output (specify twice for very verbose/build.rs output)
--ignore-rust-version
Ignore `rust-version` specification in packages
--future-incompat-report
Outputs a future incompatibility report at the end of the build
--config <KEY=VALUE>
Override a configuration value
-Z <FLAG>
Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
Filter options:
--run-ignored <WHICH>
Run ignored tests
Possible values:
- default: Run non-ignored tests
- only: Run ignored tests
- all: Run both ignored and non-ignored tests
--partition <PARTITION>
Test partition, e.g. hash:1/2 or count:2/3
--platform-filter <PLATFORM>
Filter test binaries by build platform (DEPRECATED)
Instead, use -E with 'platform(host)' or 'platform(target)'.
[default: any]
[possible values: target, host, any]
-E, --filterset <EXPR>
Test filterset (see
<https://nexte.st/docs/filtersets>)
--ignore-default-filter
Ignore the default filter configured in the profile.
By default, all filtersets are intersected with the default filter configured in the
profile. This flag disables that behavior.
This flag doesn't change the definition of the `default()` filterset.
Runner options:
--no-run
Compile, but don't run tests
-j, --test-threads <N>
Number of tests to run simultaneously [possible values: integer or "num-cpus"] [default:
from profile]
[env: NEXTEST_TEST_THREADS=]
[aliases: jobs]
--retries <N>
Number of retries for failing tests [default: from profile]
[env: NEXTEST_RETRIES=]
--fail-fast
Cancel test run on the first failure
--no-fail-fast
Run all tests regardless of failure
--no-tests=<ACTION>
Behavior if there are no tests to run.
The default is currently `warn`, but it will change to `fail` in the future.
[env: NEXTEST_NO_TESTS=]
Possible values:
- pass: Silently exit with code 0
- warn: Produce a warning and exit with code 0
- fail: Produce an error message and exit with code 4
--no-capture
Run tests serially and do not capture output
Reporter options:
--failure-output <WHEN>
Output stdout and stderr on failure
[env: NEXTEST_FAILURE_OUTPUT=]
[possible values: immediate, immediate-final, final, never]
--success-output <WHEN>
Output stdout and stderr on success
[env: NEXTEST_SUCCESS_OUTPUT=]
[possible values: immediate, immediate-final, final, never]
--status-level <LEVEL>
Test statuses to output
[env: NEXTEST_STATUS_LEVEL=]
[possible values: none, fail, retry, slow, leak, pass, skip, all]
--final-status-level <LEVEL>
Test statuses to output at the end of the run
[env: NEXTEST_FINAL_STATUS_LEVEL=]
[possible values: none, fail, flaky, slow, skip, pass, all]
--hide-progress-bar
Do not display the progress bar
[env: NEXTEST_HIDE_PROGRESS_BAR=]
--message-format <FORMAT>
Format to use for test results (experimental)
[env: NEXTEST_MESSAGE_FORMAT=]
[default: human]
Possible values:
- human: The default output format
- libtest-json: Output test information in the same format as libtest
- libtest-json-plus: Output test information in the same format as libtest, with a
`nextest` subobject that includes additional metadata
--message-format-version <VERSION>
Version of structured message-format to use (experimental).
This allows the machine-readable formats to use a stable structure for consistent
consumption across changes to nextest. If not specified, the latest version is used.
[env: NEXTEST_MESSAGE_FORMAT_VERSION=]
Reuse build options:
--archive-file <PATH>
Path to nextest archive
--archive-format <FORMAT>
Archive format
[default: auto]
[possible values: auto, tar-zst]
--extract-to <DIR>
Destination directory to extract archive to [default: temporary directory]
--extract-overwrite
Overwrite files in destination directory while extracting archive
--persist-extract-tempdir
Persist extracted temporary directory
--cargo-metadata <PATH>
Path to cargo metadata JSON
--workspace-remap <PATH>
Remapping for the workspace root
--binaries-metadata <PATH>
Path to binaries-metadata JSON
--target-dir-remap <PATH>
Remapping for the target directory
Config options:
--config-file <PATH>
Config file [default: workspace-root/.config/nextest.toml]
--tool-config-file <TOOL:ABS_PATH>
Tool-specific config files
Some tools on top of nextest may want to set up their own default configuration but
prioritize user configuration on top. Use this argument to insert configuration that's
lower than --config-file in priority but above the default config shipped with nextest.
Arguments are specified in the format "tool:abs_path", for example
"my-tool:/path/to/nextest.toml" (or "my-tool:C:\\path\\to\\nextest.toml" on Windows).
Paths must be absolute.
This argument may be specified multiple times. Files that come later are lower priority
than those that come earlier.
--override-version-check
Override checks for the minimum version defined in nextest's config.
Repository and tool-specific configuration files can specify minimum required and
recommended versions of nextest. This option overrides those checks.
-P, --profile <PROFILE>
The nextest profile to use.
Nextest's configuration supports multiple profiles, which can be used to set up different
configurations for different purposes. (For example, a configuration for local runs and
one for CI.) This option selects the profile to use.
[env: NEXTEST_PROFILE=]
-
Doctests are currently not supported because of limitations in stable Rust. For now, run doctests in a separate step with
cargo test --doc
. ↩