How do I display only test classes where tests exist?

โš“ rust    ๐Ÿ“… 2025-06-03    ๐Ÿ‘ค surdeus    ๐Ÿ‘๏ธ 1      

surdeus

I am reading the rust book and follow along. This is what I thought is important in my main.rs file:

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_get_first_word() {
        let s1 = String::from("a b c");
        let s2 = String::from("รฉlan ah");
        assert_eq!(get_first_word(&s1), "a");
        assert_eq!(get_first_word(&s2), "รฉlan");
    }
}

it is the only place where I used mod tests #[cfg(test)]
yet I get this output, all warnings are unused warnings:

warning: `hello_cargo` (bin "hello_cargo" test) generated 5 warnings (run `cargo fix --bin "hello_cargo" --tests` to apply 1 suggestion)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.03s
     Running unittests src/lib.rs (target/debug/deps/hello_cargo-390c22ba899df2a1)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/main.rs (target/debug/deps/hello_cargo-6fd24f2278d42774)

running 1 test
test tests::test_get_first_word ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests hello_cargo

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

how can I turn the other test classes off? Thanks!

6 posts - 2 participants

Read full topic

๐Ÿท๏ธ rust_feed