Do you enable tracing-subscriber for tests?
⚓ Rust 📅 2026-06-19 👤 surdeus 👁️ 1One of the pain points when writing tests for Axum applications is debugging what went wrong. One thing I've been doing is keeping a test helper to setup a tracing subscribing on my test helpers to add to the test when debugging. i.e.
// t.rs
#[allow(unused)]
pub(crate) fn setup_tracing() {
let _ = tracing_subscriber::fmt()
.with_env_filter("debug,tower_http=trace")
.with_test_writer()
.try_init();
}
...
#[tokio::test]
async fn test_foo() -> Result<()> {
t::setup_tracking();
...
}
I'm curious if people instead always setup tracing when running tests. And if so where would they enable it? AFAIU Rust's built-in test runner doesn't have something like Go's TestMain
I'm also curious what debugging strategies besides println! do y'all use.
1 post - 1 participant
🏷️ Rust_feed