From 0d69c6b2960a4092cabb136a8f519cd978c76f0e Mon Sep 17 00:00:00 2001 From: DnOnith Date: Tue, 3 Mar 2026 22:32:24 +0100 Subject: [PATCH] added tests4 tasks requires user to ignore a testcase --- exercises/17_tests/tests4.rs | 11 +++++++++++ rustlings-macros/info.toml | 11 +++++++++++ solutions/17_tests/tests4.rs | 11 +++++++++++ 3 files changed, 33 insertions(+) create mode 100644 exercises/17_tests/tests4.rs create mode 100644 solutions/17_tests/tests4.rs 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"); + } +}