-
-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Labels
Description
When testing async
code I use the #[tokio::test]
annotation instead of #[test]
. This simplifies the tests because I do not need to manually configure a runtime. However cargo-mutants
does not recognise that these are test functions and proceeds to mutate them.
Cargo.toml
:
[package]
name = "cargo-mutants-tokio-test"
version = "0.1.0"
edition = "2024"
[dependencies]
tokio = { version = "1.41.1", features = ["macros", "rt"] }
src/lib.rs
:
#[test]
fn test() {
println!("Hello")
}
#[tokio::test]
async fn tokio_test() {
println!("Hello")
}
Terminal:
$ cargo install --git "https://github.com/sourcefrog/cargo-mutants" --locked
Updating git repository `https://github.com/sourcefrog/cargo-mutants`
Ignored package `cargo-mutants v25.3.1 (https://github.com/sourcefrog/cargo-mutants#49940940)` is already installed, use --force to override
$ cargo mutants
Found 1 mutant to test
ok Unmutated baseline in 3.6s build + 0.1s test
INFO Auto-set test timeout to 20s
MISSED src/lib.rs:8:5: replace tokio_test with () in 0.3s build + 0.1s test
1 mutant tested in 4s: 1 missed
sourcefrog