Skip to main content

TestApp

Struct TestApp 

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

Managed Tauri application lifecycle for integration testing.

Spawns a Tauri app as a child process, waits for the Victauri MCP server to become healthy, and provides connected VictauriClient instances. The app is killed when the TestApp is dropped.

§Example

use victauri_test::TestApp;

#[tokio::test]
async fn my_app_works() {
    let app = TestApp::spawn("cargo run -p my-app").await.unwrap();
    let mut client = app.client().await.unwrap();
    client.click_by_text("Submit").await.unwrap();
    client.expect_text("Success").await.unwrap();
}

Implementations§

Source§

impl TestApp

Source

pub async fn spawn(cmd: &str) -> Result<Self, TestError>

Spawn an application from a shell command and wait for it to become ready.

Polls the Victauri health endpoint until it responds (up to 30 seconds). Uses port auto-discovery via temp files, falling back to env vars and defaults.

§Errors

Returns TestError::Connection if the app fails to start or the health endpoint doesn’t respond within the timeout.

Source

pub async fn spawn_with_options( cmd: &str, port: Option<u16>, timeout: Duration, ) -> Result<Self, TestError>

Spawn with explicit port and timeout configuration.

§Errors

Returns TestError::Connection if the app fails to start or the health endpoint doesn’t respond within the timeout.

Source

pub async fn spawn_demo() -> Result<Self, TestError>

Spawn the bundled demo app from the workspace.

Equivalent to TestApp::spawn("cargo run -p demo-app") but with appropriate environment variables set.

§Errors

Returns TestError::Connection if the demo app fails to start.

Source

pub async fn attach(port: u16, token: Option<String>) -> Result<Self, TestError>

Connect to an already-running Victauri app (no process management).

Useful when the app is started externally (e.g., by CI or a dev script).

§Errors

Returns TestError::Connection if the health endpoint doesn’t respond.

Source

pub async fn client(&self) -> Result<VictauriClient, TestError>

Create a new connected VictauriClient for this app.

Each call returns a fresh MCP session.

§Errors

Returns errors from VictauriClient::connect_with_token.

Source

pub fn port(&self) -> u16

The port the MCP server is running on.

Trait Implementations§

Source§

impl Drop for TestApp

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more