I'm running some tests with cargo test
and I want the tests to be sorted in alphabetical order. If I do cargo run
I get something like the following:
test node::tests::start_node::get_value_start ... ok
test node::tests::start_node::get_value ... ok
test node::tests::start_node::set_value ... ok
test node::tests::main_node::test_new ... ok
test main_tests::run_checks ... ok
test node::tests::start_node::test_new ... ok
test sigmoid::tests::sig_deriv_f32 ... ok
test sigmoid::tests::sig_deriv_inf::test_f32 ... ok
test sigmoid::tests::sig_deriv_inf::test_f64 ... ok
test training_data::tests::iter_chunks ... ok
test training_data::tests::get_chunks ... ok
test sigmoid::tests::sig_inf::test_f64 ... ok
test sigmoid::tests::sig_f32 ... ok
test sigmoid::tests::sig_inf::test_f32 ... ok
test sigmoid::tests::sig_deriv_f64 ... ok
test sigmoid::tests::sig_f64 ... ok
and the tests are output in a different, seemingly random order each time.
Is there a way to output the tests so that they are sorted alphabetically, something like this:
test main_tests::run_checks ... ok
test node::tests::main_node::test_new ... ok
test node::tests::start_node::get_value_start ... ok
test node::tests::start_node::get_value ... ok
test node::tests::start_node::set_value ... ok
test node::tests::start_node::test_new ... ok
test sigmoid::tests::sig_deriv_f32 ... ok
test sigmoid::tests::sig_deriv_f64 ... ok
test sigmoid::tests::sig_deriv_inf::test_f32 ... ok
test sigmoid::tests::sig_deriv_inf::test_f64 ... ok
test sigmoid::tests::sig_f32 ... ok
test sigmoid::tests::sig_f64 ... ok
test sigmoid::tests::sig_inf::test_f32 ... ok
test sigmoid::tests::sig_inf::test_f64 ... ok
test training_data::tests::iter_chunks ... ok
test training_data::tests::get_chunks ... ok
CodePudding user response:
They already are run alphabetically by default, the problem is they're also run in parallel and output their result as soon as possible to save you some time. If you want the output in sorted order you'd have to run the tests consecutively by limiting the test framework to one thread:
cargo test -- --test-threads=1
Note that this will most likely increase the time the tests take.