mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-03-31 03:29:19 +00:00
added tests4
tasks requires user to ignore a testcase
This commit is contained in:
parent
064f057b10
commit
0d69c6b296
11
exercises/17_tests/tests4.rs
Normal file
11
exercises/17_tests/tests4.rs
Normal file
@ -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");
|
||||
}
|
||||
}
|
||||
@ -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]]
|
||||
|
||||
11
solutions/17_tests/tests4.rs
Normal file
11
solutions/17_tests/tests4.rs
Normal file
@ -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");
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user