You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The test functions within our code blocks will not actually be run in
any case, so let's mark these tests as `no_run`.
In the examples, let's demonstrate the behavior that the expected
string must be a substring of the panic message.
Let's also tighten up some wording.
The *`ignore` [attribute][attributes]* can be used with the [`test` attribute][attributes.testing.test] to tell the test harness to not execute that function as a test.
The *`should_panic` [attribute][attributes]* causes a test to pass only if the [test function][attributes.testing.test] to which the attribute is applied panics.
> `rustc` currently ignores subsequent `should_panic` attributes and emits a future-compatibility warning. This may become a hard error in the future.
176
175
177
176
r[attributes.testing.should_panic.expected]
178
-
Thestringspecifiedwiththe [MetaNameValueStr] formorthe `expected` keyin [MetaListNameValueStr] indicatesthatthestringmustappearsomewherewithinthepanicmessage.Ifthestringisnotfoundinthemessage, thenthetestwillfail.
177
+
When the [MetaNameValueStr] form or the [MetaListNameValueStr] form with the `expected` key is used, the given string must appear somewhere within the panic message for the test to pass.
179
178
180
179
r[attributes.testing.should_panic.return]
181
180
The return type of the test function must be `()`.
0 commit comments