pub trait TestCase {
// Required methods
fn name(&self) -> &str;
fn modules(&self) -> &[&str];
fn run(&self);
fn ignore(&self) -> Ignore;
fn should_panic(&self) -> ShouldPanic;
fn message(&self) -> Option<&'static str>;
}Expand description
Defines a test case executable by the test runner.
Any type implementing this trait can be passed to the test runner using the #[test_case]
attribute. For most cases, using the #[test] attribute provided by this crate is sufficient.
See the custom_test_frameworks
language feature for more information about using the #[test_case] attribute.
Required Methods§
Sourcefn run(&self)
fn run(&self)
The actual test itself.
If this method panics, the test is considered a failure. Otherwise, the test is considered to have passed.
Sourcefn ignore(&self) -> Ignore
fn ignore(&self) -> Ignore
Whether the test should be excluded or not.
If this method returns Ignore::Yes, the test function will not be run at all (but it will
still be compiled). This allows for time-consuming or expensive tests to be conditionally
disabled.
Sourcefn should_panic(&self) -> ShouldPanic
fn should_panic(&self) -> ShouldPanic
Whether the test is expected to panic.