pub struct AppTester<App>where
App: App,{ /* private fields */ }Expand description
AppTester is a simplified execution environment for Crux apps for use in
tests.
Please note that the AppTester is strictly no longer required now that Crux
has a new Command API. To test apps without the AppTester, you can call
the update method on your app directly, and then inspect the effects
returned by the command. For examples of how to do this, consult any of the
examples in the Crux repository.
The AppTester is still provided for backwards compatibility, and to allow you to
migrate to the new API without changing the tests,
giving you increased confidence in your refactor.
Create an instance of AppTester with your App and an Effect type
using AppTester::default.
for example:
let app = AppTester::<ExampleApp, ExampleEffect>::default();Implementationsยง
Sourceยงimpl<App> AppTester<App>
impl<App> AppTester<App>
Sourcepub fn new(app: App) -> Self
pub fn new(app: App) -> Self
Create an AppTester instance for an existing app instance. This can be used if your App
has a constructor other than Default, for example when used as a child app and expecting
configuration from the parent
Sourcepub fn update(
&self,
event: App::Event,
model: &mut App::Model,
) -> Update<App::Effect, App::Event>
pub fn update( &self, event: App::Event, model: &mut App::Model, ) -> Update<App::Effect, App::Event>
Sourcepub fn resolve<Output>(
&self,
request: &mut impl Resolvable<Output>,
value: Output,
) -> Result<Update<App::Effect, App::Event>>
pub fn resolve<Output>( &self, request: &mut impl Resolvable<Output>, value: Output, ) -> Result<Update<App::Effect, App::Event>>
Sourcepub fn resolve_to_event_then_update<Op: Operation>(
&self,
request: &mut Request<Op>,
value: Op::Output,
model: &mut App::Model,
) -> Update<App::Effect, App::Event>
pub fn resolve_to_event_then_update<Op: Operation>( &self, request: &mut Request<Op>, value: Op::Output, model: &mut App::Model, ) -> Update<App::Effect, App::Event>
Resolve an effect request from previous update, then run the resulting event
This helper is useful for the common case where one expects the effect to resolve to exactly one event, which should then be run by the app.
ยงPanics
Panics if the request cannot be resolved.