HeadlessUnitTestSession
struct · ferroui-headless · v0.5.0
struct HeadlessUnitTestSession
Headless unit test session that needs to be used by the actual testing
framework. All UI tests are supposed to be executed from one of the
dispatch methods to keep execution flow on the UI thread. Disposing
unit test session stops internal dispatcher loop.
Members
dispatchdispatch_resultdispatch_taskdisposedispose_asyncstart_newstart_new_with_isolationget_or_start_for_assembly
dispatch
fn dispatch(self: &Self, action: impl FnOnce() -> () + Send + 'static, cancellation_token: CancellationToken) -> HeadlessUnitTestTask<()>
Queues an action on the dispatcher thread; see
dispatch_task.
dispatch_result
fn dispatch_result<TResult: Send + 'static>(self: &Self, action: impl FnOnce() -> TResult + Send + 'static, cancellation_token: CancellationToken) -> HeadlessUnitTestTask<TResult>
Queues an action with a result on the dispatcher thread; see
dispatch_task.
dispatch_task
fn dispatch_task<F, Fut>(self: &Self, action: F, cancellation_token: CancellationToken) -> HeadlessUnitTestTask<<Fut as >::Output>
where F: FnOnce() -> Fut + Send + 'static,
Fut: Future + 'static,
<Fut as >::Output: Send + 'static
Dispatch method queues an async operation on the dispatcher thread,
creates a new application instance, setting the application services,
and runs action parameter.
action is the action to execute on the dispatcher thread with the
services; the future it returns never leaves the dispatcher thread.
cancellation_token is the cancellation token to cancel execution.
Panics
If global session was already cancelled and thread killed, it's not
possible to dispatch any actions again (ObjectDisposedException).
dispose
fn dispose(self: &Self)
dispose_async
async fn dispose_async(self: &Self)
The asynchronous form of dispose. The dispatch
thread is joined before the future is returned to its first poll:
there is no task to await in its place.
start_new
fn start_new(entry_point_type: fn() -> AppBuilder) -> Arc<HeadlessUnitTestSession>
Creates instance of HeadlessUnitTestSession with the
FerroTestIsolationLevel::PerTest isolation.
entry_point_type is the parameter from which AppBuilder should
be created: the function that builds the application
(AppBuilder::configure::<TApp> for an application class).
start_new_with_isolation
fn start_new_with_isolation(entry_point_type: fn() -> AppBuilder, isolation_level: FerroTestIsolationLevel) -> Arc<HeadlessUnitTestSession>
Creates instance of HeadlessUnitTestSession.
entry_point_type is the parameter from which AppBuilder should
be created. isolation_level defines the isolation level for
headless unit tests.
Panics
Raises the panic of the entry point again.
get_or_start_for_assembly
fn get_or_start_for_assembly(assembly: Option<&FerroTestAssembly>) -> Arc<HeadlessUnitTestSession>
Creates a session from the test application attribute of the assembly or reuses any existing. If the attribute doesn't exist, empty application is used.
None is the assembly of the session itself.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyClassDefaultsIDisposableErasedDestructorIntoEither
Availability
Extracted for x86_64-unknown-linux-gnu, aarch64-apple-darwin. Cargo features are listed in the crate index.