diff --git a/exercises/17_tests/tests4.rs b/exercises/17_tests/tests4.rs new file mode 100644 index 00000000..ef5fd7e6 --- /dev/null +++ b/exercises/17_tests/tests4.rs @@ -0,0 +1,11 @@ +fn main() {} + +#[cfg(test)] +mod tests { + //TODO make sure this test does not run + #[test] + fn ignore_test() { + // Do not change this line + panic!("The test wasn't ignored"); + } +} diff --git a/rustlings-macros/info.toml b/rustlings-macros/info.toml index e42b0f26..ec48590a 100644 --- a/rustlings-macros/info.toml +++ b/rustlings-macros/info.toml @@ -868,6 +868,17 @@ To handle that, you need to add a special attribute to the test function. You can refer to the docs: https://doc.rust-lang.org/book/ch11-01-writing-tests.html#checking-for-panics-with-should_panic""" +[[exercises]] +name = "tests4" +dir = "17_tests" +hint = """ +The test always panics, so we need a way to simply ignore it. + +For this, similarly to the exercise tests3, we can add a special attribute to the test function. + +You can refer to the docs: +https://doc.rust-lang.org/book/ch11-02-running-tests.html#ignoring-tests-unless-specifically-requested +""" # STANDARD LIBRARY TYPES [[exercises]] diff --git a/solutions/17_tests/tests4.rs b/solutions/17_tests/tests4.rs new file mode 100644 index 00000000..3a0a645d --- /dev/null +++ b/solutions/17_tests/tests4.rs @@ -0,0 +1,11 @@ +fn main() {} + +#[cfg(test)] +mod tests { + + #[test] + #[ignore] //this line simply ignores the test + fn ignore_test() { + panic!("The test wasn't ignored"); + } +}