TestCase

Trait TestCase 

Source
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§

Source

fn name(&self) -> &str

The name of the test.

Source

fn modules(&self) -> &[&str]

The module the test is in.

Source

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.

Source

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.

Source

fn should_panic(&self) -> ShouldPanic

Whether the test is expected to panic.

Source

fn message(&self) -> Option<&'static str>

Returns the ignore message, if it exists.

Implementors§