Skip to main content

FixtureManager

Struct FixtureManager 

Source
pub struct FixtureManager { /* private fields */ }
Expand description

Manager for test fixtures with dependency-ordered setup/teardown.

§Example

use jugar_probar::fixture::{FixtureManager, Fixture};

let mut manager = FixtureManager::new();
manager.register(BrowserFixture::new());
manager.register(DatabaseFixture::new());

// Set up all fixtures in priority order
manager.setup_all()?;

// Run tests...

// Tear down all fixtures in reverse order
manager.teardown_all()?;

Implementations§

Source§

impl FixtureManager

Source

pub fn new() -> Self

Create a new fixture manager.

Source

pub fn register<F: Fixture + 'static>(&mut self, fixture: F)

Register a fixture with the manager.

If a fixture of the same type is already registered, it will be replaced.

Source

pub fn is_registered<F: Fixture + 'static>(&self) -> bool

Check if a fixture type is registered.

Source

pub fn count(&self) -> usize

Get the number of registered fixtures.

Source

pub fn state<F: Fixture + 'static>(&self) -> Option<FixtureState>

Get the state of a fixture.

Source

pub fn get<F: Fixture + 'static>(&self) -> Option<&F>

Get a reference to a fixture by type.

Source

pub fn get_mut<F: Fixture + 'static>(&mut self) -> Option<&mut F>

Get a mutable reference to a fixture by type.

Source

pub fn setup_all(&mut self) -> ProbarResult<()>

Set up all registered fixtures in priority order (highest first).

§Errors

Returns an error if any fixture setup fails. Previously set up fixtures are torn down before returning the error.

Source

pub fn teardown_all(&mut self) -> ProbarResult<()>

Tear down all fixtures in reverse setup order.

§Errors

Returns an error if any fixture teardown fails. Other fixtures will still be torn down, but the first error is returned.

Source

pub fn setup<F: Fixture + 'static>(&mut self) -> ProbarResult<()>

Set up a specific fixture by type.

§Errors

Returns an error if the fixture is not registered or setup fails.

Source

pub fn teardown<F: Fixture + 'static>(&mut self) -> ProbarResult<()>

Tear down a specific fixture by type.

§Errors

Returns an error if the fixture is not registered or teardown fails.

Source

pub fn reset(&mut self)

Reset all fixtures to the registered state without running teardown.

Source

pub fn unregister<F: Fixture + 'static>(&mut self) -> bool

Unregister a fixture by type.

Source

pub fn clear(&mut self)

Clear all registered fixtures.

Source

pub fn list(&self) -> Vec<&str>

List all registered fixture names.

Trait Implementations§

Source§

impl Debug for FixtureManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FixtureManager

Source§

fn default() -> FixtureManager

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.