运行 cargo test
没有显示所有 4 个测试,也没有显示我运行的任何测试的任何输出。
我有4个测试:
test common::tests::test_workingdays
test documents::tests::create_docs
test emailer::tests::test_attachments
test emailer::tests::test_format_attachments
$ cargo test
Compiling te-pm-analytics v0.1.0 (/home/charlie/thoughtexpress/rust/te-pm-analytics)
Finished test [unoptimized + debuginfo] target(s) in 2.44s
Running target/debug/deps/main-253a09bf91ed177c
running 4 tests
test common::tests::test_workingdays ... ok
test emailer::tests::test_attachments ... FAILED
error: test failed, to rerun pass '--bin main'
它只运行其中两个,甚至不给我有关失败的信息。
最佳答案
所以发生这种情况的原因是我进行的 4 次测试
test common::tests::test_workingdays
test documents::tests::create_docs
test emailer::tests::test_attachments
test emailer::tests::test_format_attachments
两者 test_attachments
和 test_format_attachments
但是失败了 test_format_attachments
有一个 std::process::exit(1)
它正在测试的函数内部存在条件,因此它在测试能够返回之前终止了该进程。
关于testing - cargo 测试不显示任何输出也不显示所有测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65902338/