Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ bin = [
{ name = "tests2_sol", path = "../solutions/17_tests/tests2.rs" },
{ name = "tests3", path = "../exercises/17_tests/tests3.rs" },
{ name = "tests3_sol", path = "../solutions/17_tests/tests3.rs" },
{ name = "tests4", path = "../exercises/17_tests/tests4.rs" },
{ name = "tests4_sol", path = "../solutions/17_tests/tests4.rs" },
{ name = "iterators1", path = "../exercises/18_iterators/iterators1.rs" },
{ name = "iterators1_sol", path = "../solutions/18_iterators/iterators1.rs" },
{ name = "iterators2", path = "../exercises/18_iterators/iterators2.rs" },
Expand Down
11 changes: 11 additions & 0 deletions exercises/17_tests/tests4.rs
Original file line number Diff line number Diff line change
@@ -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");
}
}
11 changes: 11 additions & 0 deletions rustlings-macros/info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down
11 changes: 11 additions & 0 deletions solutions/17_tests/tests4.rs
Original file line number Diff line number Diff line change
@@ -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");
}
}