Hello everyone,
I am working on my first big Rust project. I am using a macro which helps me a lot when I have to write tests, here it is:
macro_rules! run_tests {
($($name:ident: $values:expr,) *) => {
$(
#[test]
fn $name () {
let (left, right) = $values;
assert_eq!(left, right);
}
)*
}
}
It allows me to create a test very simply, like this one:
run_tests! {
it_works: (2 + 2, 4),
}
This worked fine until now, but since the release of Rust 1.30.0, I get the following warning during compilation:
warning: #[test] attribute should not be used on macros. Use #[cfg(test)] instead.
--> src/....
|
100 | / run_tests! {
101 | | it_works: (
102 | | 2 + 2,
103 | | 4
104 | | ),
105 | | }
| |_____^
How can I fix this warning ? I have to use #[test] since I want this piece of code to be tested. So I don't know what to do..
Please help me!
Cheers.