Skip to main content

HeadlessUnitTestSession

Struct HeadlessUnitTestSession 

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

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.

Implementations§

Source§

impl HeadlessUnitTestSession

Source

pub fn dispatch( &self, action: impl FnOnce() + Send + 'static, cancellation_token: CancellationToken, ) -> HeadlessUnitTestTask<()>

Queues an action on the dispatcher thread; see dispatch_task.

Source

pub fn dispatch_result<TResult: Send + 'static>( &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.

Source

pub fn dispatch_task<F, Fut>( &self, action: F, cancellation_token: CancellationToken, ) -> HeadlessUnitTestTask<Fut::Output>
where F: FnOnce() -> Fut + Send + 'static, Fut: Future + 'static, Fut::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).

Source

pub fn dispose(&self)

Source

pub async fn dispose_async(&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.

Source

pub 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).

Source

pub 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.

Source

pub 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§

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> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.