TestCase

Trait TestCase 

Source
pub trait TestCase {
    // Required methods
    fn qualified_name(&self) -> &'static str;
    fn run(&self);
    fn ignore(&self) -> Ignore;
    fn should_panic(&self) -> ShouldPanic;

    // Provided methods
    fn name(&self) -> &'static str { ... }
    fn modules(&self) -> Option<&'static str> { ... }
}
Expand description

A trait representing a test case that can be run and provides metadata about itself.

Required Methods§

Source

fn qualified_name(&self) -> &'static str

Returns the full name of the test case, including module path (e.g., “my_crate::tests::my_test”).

Source

fn run(&self)

Runs the test case. This should not panic if the test passes.

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.

Provided Methods§

Source

fn name(&self) -> &'static str

Returns the function name of the test case, without module path.

Source

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

Returns the module path of the test case, if available.

Implementors§