你如何 运行 主二进制文件然后 运行 在 Rust 中基于它进行测试?

How do you run the main binary and then run tests based on it in Rust?

我已经编写了一个网络服务器,它需要一些复杂的设置和拆卸,并且正在尝试编写单元测试。 Axum 确实提供了使用 Tower OneShot 功能的示例,但这些示例并不容易实现完整的设置流程。我如何 运行 完整的服务器,然后 运行 额外的代码来测试它(使用 reqwest) cargo test?

参见本示例中的 the_real_deal https://github.com/tokio-rs/axum/blob/main/examples/testing/src/main.rs