pub struct TestEnv { /* private fields */ }Expand description
测试环境管理器
Implementations§
Source§impl TestEnv
impl TestEnv
Sourcepub fn new(config: TestEnvConfig) -> Self
pub fn new(config: TestEnvConfig) -> Self
创建新的测试环境
Sourcepub fn default_env() -> Self
pub fn default_env() -> Self
创建默认测试环境
Sourcepub fn setup(&self) -> TestingResult<()>
pub fn setup(&self) -> TestingResult<()>
初始化测试环境
Sourcepub fn teardown(&self) -> TestingResult<()>
pub fn teardown(&self) -> TestingResult<()>
清理测试环境
Sourcepub fn state(&self) -> TestEnvState
pub fn state(&self) -> TestEnvState
获取环境状态
Sourcepub fn on_cleanup<F>(&self, handler: F)
pub fn on_cleanup<F>(&self, handler: F)
注册清理函数
Sourcepub fn config(&self) -> &TestEnvConfig
pub fn config(&self) -> &TestEnvConfig
获取配置
Sourcepub async fn with_fixture<F, R>(&self, fixture: F) -> TestingResult<R>where
F: FnOnce() -> TestingResult<R>,
pub async fn with_fixture<F, R>(&self, fixture: F) -> TestingResult<R>where
F: FnOnce() -> TestingResult<R>,
使用 fixture 运行测试
Sourcepub async fn run_test<F, Fut>(&self, test: F) -> TestingResult<()>
pub async fn run_test<F, Fut>(&self, test: F) -> TestingResult<()>
运行异步测试
Auto Trait Implementations§
impl Freeze for TestEnv
impl !RefUnwindSafe for TestEnv
impl Send for TestEnv
impl Sync for TestEnv
impl Unpin for TestEnv
impl UnsafeUnpin for TestEnv
impl !UnwindSafe for TestEnv
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more