@@ -129,11 +129,11 @@ $ echo $?
129
129
130
130
This is useful if you want to integrate ` cargo test ` into other tooling.
131
131
132
- We can invert our test's failure with another attribute: ` should_fail ` :
132
+ We can invert our test's failure with another attribute: ` should_panic ` :
133
133
134
134
``` rust
135
135
#[test]
136
- #[should_fail ]
136
+ #[should_panic ]
137
137
fn it_works () {
138
138
assert! (false );
139
139
}
@@ -163,13 +163,13 @@ equality:
163
163
164
164
``` rust
165
165
#[test]
166
- #[should_fail ]
166
+ #[should_panic ]
167
167
fn it_works () {
168
168
assert_eq! (" Hello" , " world" );
169
169
}
170
170
```
171
171
172
- Does this test pass or fail? Because of the ` should_fail ` attribute, it
172
+ Does this test pass or fail? Because of the ` should_panic ` attribute, it
173
173
passes:
174
174
175
175
``` bash
@@ -189,15 +189,15 @@ running 0 tests
189
189
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
190
190
```
191
191
192
- ` should_fail ` tests can be fragile, as it's hard to guarantee that the test
192
+ ` should_panic ` tests can be fragile, as it's hard to guarantee that the test
193
193
didn't fail for an unexpected reason. To help with this, an optional ` expected `
194
- parameter can be added to the ` should_fail ` attribute. The test harness will
194
+ parameter can be added to the ` should_panic ` attribute. The test harness will
195
195
make sure that the failure message contains the provided text. A safer version
196
196
of the example above would be:
197
197
198
198
```
199
199
#[test]
200
- #[should_fail (expected = "assertion failed")]
200
+ #[should_panic (expected = "assertion failed")]
201
201
fn it_works() {
202
202
assert_eq!("Hello", "world");
203
203
}
0 commit comments