Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way of listing all tests in a Cargo project without running them?

Waiting for a large test suite to run is painful, so I collect the duration of each test from cargo test and use a simple heuristic to find failures fast (I order by probability of failure/last run duration and run tests in that order).

This is great, but it doesn't have a way of knowing about new tests. If I could list all tests, I could detect new tests and add them to the high risk group that gets run first.

like image 519
Max Murphy Avatar asked Dec 30 '22 19:12

Max Murphy


1 Answers

You can run cargo test -- --list to list all tests and benchmarks. The output format is:

glonk: benchmark
hurz: test

1 test, 1 benchmark

You can suppress the summary line by passing the --format=terse flag.

Note that --list is a command line flag that is passed to the test binary itself, and not a Cargo flag. You can get a full list of flags accepted by the test binary using cargo test -- --help.

like image 131
Sven Marnach Avatar answered Mar 05 '23 17:03

Sven Marnach