Skip to content

Stress tests

0.9.103

Nextest can run one or more tests many times in a loop. To do so, use the --stress-count or --stress-duration options.

--stress-count=N
Run each test N times.
--stress-count=infinite
Run stress tests indefinitely.
--stress-duration=DURATION
Run tests until DURATION (e.g. 24h or 90m) has elapsed.

Stress test output

Stress tests are run in a loop, and each sub-run is annotated with a count.

For example, with cargo nextest run --stress-count 3 test_expr_deps test_expr_package_regex, you might see output like:

    Starting 2 tests across 2 binaries (49 tests skipped)
────────────
 Stress test iteration 1/3 (00:00:00 elapsed so far, 3 iterations remaining)
        PASS [   0.006s] [1/3] nextest-filtering::match test_expr_deps
        PASS [   0.006s] [1/3] nextest-filtering::match test_expr_package_regex
 Stress test [   0.007s] iteration 1/3: 2 tests run: 2 passed, 49 skipped
────────────
 Stress test iteration 2/3 (00:00:00 elapsed so far, 2 iterations remaining)
        PASS [   0.006s] [2/3] nextest-filtering::match test_expr_package_regex
        PASS [   0.006s] [2/3] nextest-filtering::match test_expr_deps
 Stress test [   0.006s] iteration 2/3: 2 tests run: 2 passed, 49 skipped
────────────
 Stress test iteration 3/3 (00:00:00 elapsed so far, 1 iteration remaining)
        PASS [   0.006s] [3/3] nextest-filtering::match test_expr_package_regex
        PASS [   0.006s] [3/3] nextest-filtering::match test_expr_deps
 Stress test [   0.006s] iteration 3/3: 2 tests run: 2 passed, 49 skipped
────────────
     Summary [   0.020s] 2 tests run: 2 passed, 49 skipped
    Starting 2 tests across 2 binaries (49 tests skipped)
────────────
 Stress test iteration 1/3 (00:00:00 elapsed so far, 3 iterations remaining)
        PASS [   0.006s] [1/3] nextest-filtering::match test_expr_deps
        PASS [   0.006s] [1/3] nextest-filtering::match test_expr_package_regex
 Stress test [   0.007s] iteration 1/3: 2 tests run: 2 passed, 49 skipped
────────────
 Stress test iteration 2/3 (00:00:00 elapsed so far, 2 iterations remaining)
        PASS [   0.006s] [2/3] nextest-filtering::match test_expr_package_regex
        PASS [   0.006s] [2/3] nextest-filtering::match test_expr_deps
 Stress test [   0.006s] iteration 2/3: 2 tests run: 2 passed, 49 skipped
────────────
 Stress test iteration 3/3 (00:00:00 elapsed so far, 1 iteration remaining)
        PASS [   0.006s] [3/3] nextest-filtering::match test_expr_package_regex
        PASS [   0.006s] [3/3] nextest-filtering::match test_expr_deps
 Stress test [   0.006s] iteration 3/3: 2 tests run: 2 passed, 49 skipped
────────────
     Summary [   0.020s] 2 tests run: 2 passed, 49 skipped

(Nextest does not currently support running the same test multiple times in parallel. It may gain support for this style of stress test in the future.)

JUnit output

With JUnit output, each <testsuite> element's name attribute is annotated with @stress-N, where N is a zero-indexed counter.

For example:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="nextest-run" tests="4" failures="0" errors="0" uuid="64f8ba6c-b032-4093-8323-0960f2b47fc9" timestamp="2025-08-24T20:53:16.476+00:00" time="0.020">
    <testsuite name="nextest-filtering::match@stress-0" tests="2" disabled="0" errors="0" failures="0">
        <testcase name="test_expr_deps" classname="nextest-filtering::match" timestamp="2025-08-24T20:53:16.478+00:00" time="0.007">
        </testcase>
        <testcase name="test_expr_package_regex" classname="nextest-filtering::match" timestamp="2025-08-24T20:53:16.478+00:00" time="0.007">
        </testcase>
    </testsuite>
    <testsuite name="nextest-filtering::match@stress-1" tests="2" disabled="0" errors="0" failures="0">
        <testcase name="test_expr_package_regex" classname="nextest-filtering::match" timestamp="2025-08-24T20:53:16.489+00:00" time="0.006">
        </testcase>
        <testcase name="test_expr_deps" classname="nextest-filtering::match" timestamp="2025-08-24T20:53:16.489+00:00" time="0.007">
        </testcase>
    </testsuite>
</testsuites>

Libtest JSON output

With libtest JSON output, each iteration of a stress test is annotated with @stress-N, where N is a zero-indexed counter.

For example:

Example output with --message-format libtest-json
{"type":"suite","event":"started","test_count":2}
{"type":"test","event":"started","name":"nextest-filtering::match@stress-0$test_expr_package_regex"}
{"type":"test","event":"started","name":"nextest-filtering::match@stress-0$test_expr_deps"}
{"type":"test","event":"ok","name":"nextest-filtering::match@stress-0$test_expr_deps","exec_time":0.005941609}
{"type":"test","event":"ok","name":"nextest-filtering::match@stress-0$test_expr_package_regex","exec_time":0.006209806}
{"type":"suite","event":"ok","passed":2,"failed":0,"ignored":0,"measured":0,"filtered_out":19,"exec_time":0.012151415}
{"type":"suite","event":"started","test_count":2}
{"type":"test","event":"started","name":"nextest-filtering::match@stress-1$test_expr_deps"}
{"type":"test","event":"started","name":"nextest-filtering::match@stress-1$test_expr_package_regex"}
{"type":"test","event":"ok","name":"nextest-filtering::match@stress-1$test_expr_deps","exec_time":0.00610633}
{"type":"test","event":"ok","name":"nextest-filtering::match@stress-1$test_expr_package_regex","exec_time":0.006165292}
{"type":"suite","event":"ok","passed":2,"failed":0,"ignored":0,"measured":0,"filtered_out":19,"exec_time":0.012271622}

With libtest-json-plus, the additional nextest object contains stress_index and stress_total (if available) fields.

Example output with --message-format libtest-json-plus
{"type":"suite","event":"started","test_count":2,"nextest":{"crate":"nextest-filtering","test_binary":"match","kind":"test","stress_index":0,"stress_total":2}}
{"type":"test","event":"started","name":"nextest-filtering::match@stress-0$test_expr_package_regex"}
{"type":"test","event":"started","name":"nextest-filtering::match@stress-0$test_expr_deps"}
{"type":"test","event":"ok","name":"nextest-filtering::match@stress-0$test_expr_deps","exec_time":0.005379185}
{"type":"test","event":"ok","name":"nextest-filtering::match@stress-0$test_expr_package_regex","exec_time":0.005661841}
{"type":"suite","event":"ok","passed":2,"failed":0,"ignored":0,"measured":0,"filtered_out":19,"exec_time":0.011041026,"nextest":{"crate":"nextest-filtering","test_binary":"match","kind":"test","stress_index":0,"stress_total":2}}
{"type":"suite","event":"started","test_count":2,"nextest":{"crate":"nextest-filtering","test_binary":"match","kind":"test","stress_index":1,"stress_total":2}}
{"type":"test","event":"started","name":"nextest-filtering::match@stress-1$test_expr_package_regex"}
{"type":"test","event":"started","name":"nextest-filtering::match@stress-1$test_expr_deps"}
{"type":"test","event":"ok","name":"nextest-filtering::match@stress-1$test_expr_deps","exec_time":0.004991222}
{"type":"test","event":"ok","name":"nextest-filtering::match@stress-1$test_expr_package_regex","exec_time":0.005451261}
{"type":"suite","event":"ok","passed":2,"failed":0,"ignored":0,"measured":0,"filtered_out":19,"exec_time":0.010442483,"nextest":{"crate":"nextest-filtering","test_binary":"match","kind":"test","stress_index":1,"stress_total":2}}