Skip to main content

Fixture

Trait Fixture 

Source
pub trait Fixture: Sized {
    // Required methods
    fn set_up() -> Result<Self>;
    fn tear_down(self) -> Result<()>;
}
Expand description

Interface for structure to be set up and torn down as part of a test. Types implementing Fixture can be passed as a reference argument to a test function.

strct MyFixture { ... }

impl Fixture for MyFixture { ... }

#[gtest]
fn test_with_fixture(my_fixture: &MyFixture) {...}

Required Methods§

Source

fn set_up() -> Result<Self>

Factory method of the Fixture.

This method is called by the test harness before the test case If this method returns an Err(...), then the test case is not evaluated and only the fixtures previously set up are torn down.

Source

fn tear_down(self) -> Result<()>

Clean up method for the fixture.

This method is called by the test harness after the test case. If the Fixture has been set up, the test harness will call this method, even if the test case failed or panicked.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<F: StaticFixture + 'static> Fixture for &'static F

Source§

fn set_up() -> Result<Self>

Source§

fn tear_down(self) -> Result<()>

Implementors§