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
impl FixtureManager
Sourcepub fn register<F: Fixture + 'static>(&mut self, fixture: F)
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.
Sourcepub fn is_registered<F: Fixture + 'static>(&self) -> bool
pub fn is_registered<F: Fixture + 'static>(&self) -> bool
Check if a fixture type is registered.
Sourcepub fn state<F: Fixture + 'static>(&self) -> Option<FixtureState>
pub fn state<F: Fixture + 'static>(&self) -> Option<FixtureState>
Get the state of a fixture.
Sourcepub fn get_mut<F: Fixture + 'static>(&mut self) -> Option<&mut F>
pub fn get_mut<F: Fixture + 'static>(&mut self) -> Option<&mut F>
Get a mutable reference to a fixture by type.
Sourcepub fn setup_all(&mut self) -> ProbarResult<()>
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.
Sourcepub fn teardown_all(&mut self) -> ProbarResult<()>
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.
Sourcepub fn setup<F: Fixture + 'static>(&mut self) -> ProbarResult<()>
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.
Sourcepub fn teardown<F: Fixture + 'static>(&mut self) -> ProbarResult<()>
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.
Sourcepub fn unregister<F: Fixture + 'static>(&mut self) -> bool
pub fn unregister<F: Fixture + 'static>(&mut self) -> bool
Unregister a fixture by type.