Closed
Description
If a function has multiple #[test]
attributes, the test is run as many times as the attribute is repeated with cargo test
.
The following code runs doing_the_thing
8 times:
mod tests {
#[test]
#[test]
#[test]
#[test]
#[test]
#[test]
#[test]
#[test]
fn doing_the_thing() {}
}
fn main() {}
I expected to see this happen: The compiler errors
Instead, this happened: It compiles fine and the test is run 8 times
Meta
rustc --version --verbose
:
rustc 1.56.1 (59eed8a2a 2021-11-01)
binary: rustc
commit-hash: 59eed8a2aac0230a8b53e89d4e99d55912ba6b35
commit-date: 2021-11-01
host: x86_64-unknown-linux-gnu
release: 1.56.1
LLVM version: 13.0.0
Happens on nightly as well:
rustc 1.58.0-nightly (d914f17ca 2021-11-16)
binary: rustc
commit-hash: d914f17ca71a33a89b2dc3436fca51b1a091559e
commit-date: 2021-11-16
host: x86_64-unknown-linux-gnu
release: 1.58.0-nightly
LLVM version: 13.0.0