Test a real mobile app with Fission LiveTest

Drive an actual inspection form on Android or iOS through stable selectors, checking validation and the recorded input rather than coordinates.
Android

What you will build

Check a real inspection journey without confusing an in-memory record, an HTTP response and a passed UI assertion.
Associate validation with the actual asset and note controls
Assert the submitted values as well as the session-only success message
Inspect native keyboard, screenshots and accessibility separately from domain tests
A coordinate identifies a place on the screen, not the control which happens to occupy it. If a longer translation moves the record button, a test which still taps the old coordinates may do the wrong thing without explaining why.
We will build an inspection form and drive it through stable semantic identifiers. The person supplies the actual asset and observation; there is no preloaded work order or button which pretends a pressure measurement occurred. The final record is an in-memory snapshot, not a durable save. That gives the test a precise outcome to assert.

Create the shared app

Complete Android SDK/NDK setup and iOS setup before testing their native hosts.
cargo install cargo-fission
fission init mobile-drive-a-real-mobile-app-with-fission-livetest
cd mobile-drive-a-real-mobile-app-with-fission-livetest
fission add-target android ios web --project-dir .
cargo add serde_yaml
Keep the generated src/main.rs. Shared state, validation, components and translations belong in src/; the platform directories supply launch and packaging.

Run the finished example

fission run --target android --project-dir .

1. Make the result testable without inventing success

The draft is retained local state. A valid submission creates a shared record; an invalid submission changes only validation feedback and leaves any previous record intact. The small pure prepare_record function is used by the actual reducer and narrow unit tests.
FormControl owns the label, required state and validation relationship. A nearby red string alone would not give the native accessibility tree the same validation information. The semantic identifiers name a control's meaning, not its current English label.
{"id":"fission-tabs-1","tabs":[{"index":0,"label":"src/app.rs","value":"src-app-rs"},{"index":1,"label":"src/app/state.rs","value":"src-app-state-rs"},{"index":2,"label":"src/app/screen.rs","value":"src-app-screen-rs"},{"index":3,"label":"src/i18n.rs","value":"src-i18n-rs"},{"index":4,"label":"src/lib.rs","value":"src-lib-rs"},{"index":5,"label":"preview/lib.rs","value":"preview-lib-rs"},{"index":6,"label":"i18n/en-US.yaml","value":"i18n-en-us-yaml"},{"index":7,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"}]}
{"id":"fission-tabs-1","index":0,"label":"src/app.rs","value":"src-app-rs"}
mod screen;
pub mod state;
pub use screen::InspectionScreen;
pub use state::InspectionState;
{"id":"fission-tabs-1","index":1,"label":"src/app/state.rs","value":"src-app-state-rs"}
use fission::prelude::*;

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct InspectionRecord {
    pub asset: String,
    pub note: String,
}

pub fn prepare_record(asset: &str, note: &str) -> Option<InspectionRecord> {
    let (asset, note) = (asset.trim(), note.trim());
    if asset.is_empty() || note.is_empty() {
        return None;
    }
    Some(InspectionRecord {
        asset: asset.to_owned(),
        note: note.to_owned(),
    })
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct InspectionState {
    pub recorded: Option<InspectionRecord>,
    pub locale: Locale,
}
impl Default for InspectionState {
    fn default() -> Self {
        Self {
            recorded: None,
            locale: Locale::from("en-US"),
        }
    }
}
impl GlobalState for InspectionState {}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn incomplete_input_never_becomes_a_record() {
        assert_eq!(prepare_record("Pump 4", " "), None);
        assert_eq!(prepare_record(" ", "Seal is intact"), None);
    }
    #[test]
    fn accepted_record_contains_trimmed_user_input() {
        assert_eq!(
            prepare_record(" Pump 4 ", " Seal is intact "),
            Some(InspectionRecord {
                asset: "Pump 4".into(),
                note: "Seal is intact".into(),
            })
        );
    }
}
{"id":"fission-tabs-1","index":2,"label":"src/app/screen.rs","value":"src-app-screen-rs"}
use super::state::{prepare_record, InspectionState};
use fission::prelude::*;

fission_component! {
    pub InspectionScreen<InspectionState> {
        state {
            asset: String = String::new(),
            note: String = String::new(),
            attempted: bool = false,
        }
    }
    view(form, state, cx) {
        let tokens = &cx.view.env().theme.tokens;
        let asset_error = (form.attempted && form.asset.trim().is_empty())
            .then(|| cx.tr("inspection.asset_required"));
        let note_error = (form.attempted && form.note.trim().is_empty())
            .then(|| cx.tr("inspection.note_required"));
    } => SafeArea(child: Scroll(child: Container(
        Column(gap: tokens.spacing.m, children: [
            Text(cx.tr("inspection.title")).size(tokens.typography.heading2_size),
            Text(cx.tr("inspection.explanation")),
            Row(gap: tokens.spacing.s, children: [
                Button(child: Text(cx.tr("language.english")), key: "english",
                    on_press: reduce { state.locale = Locale::from("en-US"); }),
                Button(child: Text(cx.tr("language.spanish")), key: "spanish",
                    on_press: reduce { state.locale = Locale::from("es-ES"); }),
            ]),
            FormControl(
                label: Some(cx.tr("inspection.asset")), required: true, error: asset_error,
                child: TextInput(
                    value: form.asset.clone(), bind(on_input): to(form.asset),
                    semantics_identifier: Some("inspection.asset".into()),
                ),
            ),
            FormControl(
                label: Some(cx.tr("inspection.note")), required: true, error: note_error,
                child: TextInput(
                    value: form.note.clone(), bind(on_input): to(form.note),
                    multiline: true, keyboard_type: TextInputType::Multiline,
                    semantics_identifier: Some("inspection.note".into()),
                ),
            ),
            Button(
                child: Text(cx.tr("inspection.record")), key: "record-inspection",
                on_press: reduce {
                    form.attempted = true;
                    if let Some(record) = prepare_record(&form.asset, &form.note) {
                        state.recorded = Some(record);
                        form.asset.clear();
                        form.note.clear();
                        form.attempted = false;
                    }
                },
            ).semantics_identifier("inspection.record"),
            if let Some(record) = &state.recorded {
                SemanticsRegion(
                    identifier: Some("inspection.result".into()), role: Role::Status,
                    child: Column(gap: tokens.spacing.s, children: [
                        Text(cx.tr("inspection.recorded")),
                        Text(record.asset.clone()).weight(tokens.typography.font_weight_semibold),
                        Text(record.note.clone()),
                    ]),
                )
            } else {
                Text(cx.tr("inspection.empty"))
            },
            Text(cx.tr("inspection.persistence")).color(tokens.colors.text_secondary),
        ])
    ).padding_all(tokens.spacing.l)))
}
{"id":"fission-tabs-1","index":3,"label":"src/i18n.rs","value":"src-i18n-rs"}
use fission::i18n::{Locale, TranslationBundle};
use fission::prelude::*;
use std::collections::HashMap;

pub fn create_env() -> Env {
    let mut env = Env::default();
    env.locale = Locale::from("en-US");
    for (locale, source) in [
        ("en-US", include_str!("../i18n/en-US.yaml")),
        ("es-ES", include_str!("../i18n/es-ES.yaml")),
    ] {
        let messages: HashMap<String, String> =
            serde_yaml::from_str(source).expect("valid task translations");
        env.i18n.add_bundle(TranslationBundle {
            locale: Locale::from(locale),
            messages,
        });
    }
    env
}

pub fn sync_env(state: &crate::app::InspectionState, env: &mut Env) {
    env.locale = state.locale.clone();
}
{"id":"fission-tabs-1","index":4,"label":"src/lib.rs","value":"src-lib-rs"}
pub mod app;
mod i18n;

use app::{InspectionScreen, InspectionState};
use fission::prelude::*;

#[cfg(not(any(target_arch = "wasm32", target_os = "android", target_os = "ios")))]
pub fn run_desktop() -> anyhow::Result<()> {
    DesktopApp::<InspectionState, _>::new(InspectionScreen)
        .with_env(i18n::create_env())
        .with_sync_env(i18n::sync_env)
        .run()
}

#[cfg(any(target_os = "android", target_os = "ios"))]
pub fn run_mobile() -> anyhow::Result<()> {
    MobileApp::<InspectionState, _>::new(InspectionScreen)
        .with_env(i18n::create_env())
        .with_sync_env(i18n::sync_env)
        .run()
}

#[cfg(target_os = "android")]
#[no_mangle]
fn android_main(app_handle: AndroidApp) {
    let app = MobileApp::<InspectionState, _>::new(InspectionScreen)
        .with_env(i18n::create_env())
        .with_sync_env(i18n::sync_env);
    #[cfg(debug_assertions)]
    let app = app.with_test_control_port(48761);
    let _ = app.run_with_android_app(app_handle);
}

#[cfg(target_arch = "wasm32")]
#[wasm_bindgen::prelude::wasm_bindgen(start)]
pub fn run_web() -> Result<(), wasm_bindgen::JsValue> {
    console_error_panic_hook::set_once();
    WebApp::<InspectionState, _>::new(InspectionScreen)
        .with_env(i18n::create_env())
        .with_sync_env(i18n::sync_env)
        .run()
        .map_err(|error| wasm_bindgen::JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1","index":5,"label":"preview/lib.rs","value":"preview-lib-rs"}
mod app;
mod i18n;

use fission::prelude::*;
use wasm_bindgen::prelude::*;

#[wasm_bindgen(start)]
pub fn run() -> Result<(), JsValue> {
    console_error_panic_hook::set_once();
    WebApp::<app::InspectionState, _>::new(app::InspectionScreen)
        .with_env(i18n::create_env())
        .with_sync_env(i18n::sync_env)
        .mount("#fission-web-mount")
        .run()
        .map_err(|error| JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1","index":6,"label":"i18n/en-US.yaml","value":"i18n-en-us-yaml"}
inspection.title: "Record an inspection"
inspection.explanation: "Name the asset you checked and describe what you found. No preloaded work order is assumed."
inspection.asset: "Asset or work reference"
inspection.note: "Inspection note"
inspection.asset_required: "Enter the asset or work reference."
inspection.note_required: "Add an inspection note."
inspection.record: "Record for this session"
inspection.recorded: "Inspection recorded for this session."
inspection.empty: "No inspection has been recorded."
inspection.persistence: "This record is kept in memory. It has not been written to a database or sent to a service."
language.english: "English"
language.spanish: "Español"
{"id":"fission-tabs-1","index":7,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"}
inspection.title: "Registrar una inspección"
inspection.explanation: "Indica el equipo revisado y describe lo que observaste. No se presupone ninguna orden precargada."
inspection.asset: "Equipo o referencia de trabajo"
inspection.note: "Nota de inspección"
inspection.asset_required: "Introduce el equipo o la referencia de trabajo."
inspection.note_required: "Añade una nota de inspección."
inspection.record: "Registrar para esta sesión"
inspection.recorded: "Inspección registrada para esta sesión."
inspection.empty: "No se ha registrado ninguna inspección."
inspection.persistence: "El registro se conserva en memoria. No se ha escrito en una base de datos ni enviado a un servicio."
language.english: "Inglés"
language.spanish: "Español"
{"id":"fission-tabs-1"}
Try a blank submission, then enter an asset and an observation. A valid record must contain your actual text. Submit another blank form and confirm that the previous record remains visible.
Show the app preview
Hide the app preview

2. Drive validation and record creation through the real shell

First run the shared rule tests:
cargo test --lib
On Android, the debug-only entrypoint above enables the generated launch script's forwarded port. Do not ship that development control interface as a production feature. Launch one test target at a time:
fission doctor android --project-dir .
fission run --target android --project-dir .
export TEST_PORT=48761
For iOS, use macOS and pass a different port into the simulator process:
fission doctor ios --project-dir .
FISSION_TEST_CONTROL_PORT=48762 fission run --target ios --project-dir .
export TEST_PORT=48762
In a second terminal on the launching machine, set the matching TEST_PORT and issue these requests:
curl --fail-with-body "http://127.0.0.1:${TEST_PORT}/health"
curl --fail-with-body -H 'Content-Type: application/json' \
  --data '{"cmd":"ActivateSelector","query":{"selector":{"kind":"semantic_identifier","identifier":"inspection.record"}}}' \
  "http://127.0.0.1:${TEST_PORT}/cmd"
curl --fail-with-body -H 'Content-Type: application/json' \
  --data '{"cmd":"WaitForText","text":"Add an inspection note.","timeout_ms":5000}' \
  "http://127.0.0.1:${TEST_PORT}/cmd"
curl --fail-with-body -H 'Content-Type: application/json' \
  --data '{"cmd":"FillText","query":{"selector":{"kind":"semantic_identifier","identifier":"inspection.asset"}},"text":"Loading bay door 2"}' \
  "http://127.0.0.1:${TEST_PORT}/cmd"
curl --fail-with-body -H 'Content-Type: application/json' \
  --data '{"cmd":"FillText","query":{"selector":{"kind":"semantic_identifier","identifier":"inspection.note"}},"text":"Seal intact; latch closes without force."}' \
  "http://127.0.0.1:${TEST_PORT}/cmd"
curl --fail-with-body -H 'Content-Type: application/json' \
  --data '{"cmd":"ActivateSelector","query":{"selector":{"kind":"semantic_identifier","identifier":"inspection.record"}}}' \
  "http://127.0.0.1:${TEST_PORT}/cmd"
curl --fail-with-body -H 'Content-Type: application/json' \
  --data '{"cmd":"WaitForText","text":"Inspection recorded for this session.","timeout_ms":5000}' \
  "http://127.0.0.1:${TEST_PORT}/cmd"
curl --fail-with-body -H 'Content-Type: application/json' \
  --data '{"cmd":"GetTree"}' "http://127.0.0.1:${TEST_PORT}/cmd"
Inspect every JSON response. HTTP success is not a passed LiveTest assertion: Error and SelectorError are failures. The text waits must return status: Ok, and the final semantic tree must contain the actual asset and observation under inspection.result. A success label alone would not establish that the right input was recorded.
These text assertions deliberately use the default English bundle. Repeat the journey in Spanish using its corresponding messages; control selection still uses the same identifiers. For a repeatable suite, use the LiveTest client to assert returned values and stop the run on a command failure.
Check the empty-input path and the actual submitted values, not just the existence of a success caption. Record the target, source revision and result together.
Show the app preview
Hide the app preview

3. Inspect the rendered screen as well as its semantics

Use CaptureScreenshot through the same /cmd endpoint and decode its png_base64 result on the test client. The iOS testing tutorial shows that command. Inspect small-screen scrolling, the open keyboard, longer translations and error placement. A semantic tree cannot establish that the visible layout is usable.
Run the generated-host smoke checks separately:
fission test --target android --project-dir .
fission test --target ios --project-dir .
Then follow the same journey on an Android phone and an iPhone. Check native text entry and accessibility. This workflow does not require a sensor, but simulator results still do not establish physical keyboard and device behaviour.
When durable storage is added, the button must request a Store or service effect and report durable success only after its bound completion confirms the write. Do not preserve the session-only success label and imply that persistence came for free.