Skip to content

Testing Strategy and Per-Package Commands

This page is the operational map of how the ZikZak InAppWebView monorepo proves itself: which layer of test covers which kind of failure, the exact command that runs it, and the directory you must be standing in when you run it. The single most important fact is structural rather than procedural — there is no root pubspec, so every package is its own pub root and every flutter test / flutter analyze invocation must execute inside the package that owns the file. Running from the repository root does not fail loudly; it produces a false green, which is the worst possible outcome for a gate.

Sources: AGENTS.md, tdd-profile.md

Testing in this repo is not one suite but five layers, each answering a question the layer below cannot. Dart unit and widget tests answer “does the Dart logic behave?”; source-contract scans answer “does the native source still contain the construct we depend on?”; acceptance tests answer “does the public entry point behave as a consumer would see it?”; on-device integration tests answer “does the platform WebView actually do it?”; and compiled native tests answer “does the C/C++ we ship work?”. The layers are ordered by cost, and the cheap ones deliberately carry most of the weight.

flowchart TD
A["flutter test<br/>(package test/)"] --> B["source-contract scans<br/>(Swift/ObjC as text)"]
B --> C["acceptance tests<br/>(test/acceptance/)"]
C --> D["integration_test<br/>(example/, device)"]
D --> E["compiled native tests<br/>(ctest, Linux)"]
E --> F["GYM exercises<br/>(.gym/, exit-code graded)"]

Read the diagram top-down as increasing fidelity and increasing cost: a green bottom layer is cheap and fast, a green top layer is expensive and rare. The pyramid’s practical consequence is that a change to Dart behavior should be provable without ever reaching the device layer.

Sources: AGENTS.md, tdd-profile.md

Layer Location Runner What it catches
Unit / widget <package>/test/**/*_test.dart flutter_test Dart logic, entity serialization, controller facades
Source-contract <package>/test/*_test.dart (Apple, Linux) flutter_test reading native files as text Native API drift, private-API usage, availability floors
Acceptance zikzak_inappwebview/test/acceptance/ flutter_test + inline fakes Public entry-point behavior against a faked platform
E2E / integration zikzak_inappwebview/example/integration_test/, zikzak_inappwebview_linux/example/integration_test/, zikzak_inappwebview_windows/integration_test/ integration_test on a device Real WebView navigation, cookies, screenshots, PDF
Compiled native zikzak_inappwebview_linux/linux/test/*.cc ctest C++ plugin logic that Dart tests cannot compile
GYM zikzak_inappwebview/.gym/ dart run / flutter test, exit-code graded Reflex-level regressions, warmup before graded work

Sources: gym.yaml, native_navigation_test.dart

The table below is the authoritative cwd map. Note the two packages that are absent from CI’s analyze and test matrices — zikzak_inappwebview_android and zikzak_inappwebview_module — which means a regression in either is invisible to the merge gate and must be caught by running the suite yourself.

Package cwd Runner CI matrix Notes
zikzak_inappwebview zikzak_inappwebview flutter_test yes umbrella; richest behavior tests
zikzak_inappwebview_platform_interface zikzak_inappwebview_platform_interface flutter_test yes entity/fromJson coverage, test/types/
zikzak_inappwebview_ios zikzak_inappwebview_ios flutter_test yes many Swift source-contract scans
zikzak_inappwebview_macos zikzak_inappwebview_macos flutter_test yes Swift source-contract scans, test/support/
zikzak_inappwebview_windows zikzak_inappwebview_windows flutter_test yes Dart facade only; C++ uncompiled
zikzak_inappwebview_linux zikzak_inappwebview_linux flutter_test yes plus ctest and device leg in CI
zikzak_webview_windows zikzak_webview_windows flutter_test analyze + test the DevTools fork; 2 Dart surface probes
zikzak_inappwebview_web zikzak_inappwebview_web flutter_test --platform chrome separate test-web job requires Chrome; uses dart:js_interop
zikzak_inappwebview_android zikzak_inappwebview_android flutter_test no outside both matrices
zikzak_inappwebview_module zikzak_inappwebview_module flutter_test no publish_to: none, never published

Sources: AGENTS.md, ci.yml

From inside the owning package, five command shapes cover the whole suite. The --plain-name form is the red/green instrument of the TDD loop, and it fails honestly: a name that matches nothing prints No tests ran and exits non-zero (79), so a typo can never be mistaken for a pass.

Terminal window
flutter pub get # first time / after pubspec change
flutter test # full suite
flutter test test/<file>_test.dart # one file
flutter test test/<file>_test.dart --plain-name "Behavior" # one test
flutter test --coverage # emits coverage/lcov.info
flutter analyze --no-fatal-infos # the CI lint gate

Sources: AGENTS.md, tdd-profile.md

Two flags are not optional. --concurrency=2 caps the fan-out because a single un-capped flutter test run once starved the shared host (load 260); flutter test ignores dart_test.yaml entirely, so the flag is the only lever and must be passed every time. --no-fatal-infos on flutter analyze is the CI’s actual posture: style-level infos are reported but tolerated, while a new warning in any matrix package is a red build.

Sources: AGENTS.md, ci.yml

The project constitution makes Test-Driven Development non-negotiable: a test must exist and be observed failing for the right reason before the code that makes it pass, the failure output is recorded in specs/<feature>/tdd/cycle-log.md, and tests are never weakened, skipped, or filtered to reach green. Refactoring happens only on a green suite, and never in the same commit as a behavior change. Test strength is verified rather than assumed — mutation testing where a tool exists, a deliberate-mutant spot check where it does not (no mutation or property library is present in this lockfile).

Sources: constitution.md, tdd-profile.md

The house style is deliberately austere: no mocking library at all (no mockito), no shared test-helper package, and each file builds its own minimal fixtures. Doubles are small hand-written inline fakes implementing the real port interface — _InMemoryPort implements SessionPort, _ProbeDisposable implements Disposable — and assertions are state-based on observable results rather than interaction verifications. Group names carry the spec’s FR/US id when one applies (cookie mapping (FR-005)), and DateTime.now() is never called in production code under test without an injected clock.

Sources: tdd-profile.md, webview_sessions_test.dart

One distinction matters when reading the suite: many existing tests are compile-time probes that reference a signature so drift breaks the build, which is valid but not behavioral. New tests are expected to call the real class and assert observable output. The canonical behavioral exemplar is webview_sessions_test.dart, which drives the real FileSessionStore against a temp directory through an injected SessionPort seam, with no registered platform; the canonical entity exemplar is zikzak_inappwebview_platform_interface/test/types/console_message_test.dart.

Sources: tdd-profile.md, AGENTS.md

Source-Contract Tests: The Apple Safety Net

Section titled “Source-Contract Tests: The Apple Safety Net”

A distinctive pattern in this repo is the source-contract test: a Dart test that reads the package’s .swift files as text and asserts that a required construct is present. This exists because flutter analyze and flutter test never compile the Apple native layer — so without it, every Swift contract would pass on a file that does not compile. The scanning primitive strips comments and string literals (handling Swift’s nested block comments and triple-quoted strings) so only real code tokens are matched, and it is now shared from test/support/swift_source.dart rather than copied per file.

Sources: swift_source.dart, ci.yml

The blind spot is explicit and documented rather than hidden: because these tests read text, the only thing that type-checks the Apple sources is a real build job. CI therefore runs build-ios (which compiles the #if compiler(>=6.0) arm of InAppWebView.swift on macos-15) and build-macos (which compiles the macOS package’s Swift). The pre-Swift-6 #else arm lost its only runner when macOS 14 images were retired, and the workflow says so in a comment instead of pretending coverage exists.

Sources: ci.yml, ci.yml

Native and Device Layers: What Actually Runs Where

Section titled “Native and Device Layers: What Actually Runs Where”

The device layer is platform-partial, and the honest statement of that is part of the strategy. The iOS Simulator runs the example integration suite reliably. macOS desktop fails because controller.loadData(...) never completes — the native method-channel response is lost in the headless desktop WebView and the call times out at 20s. The Android emulator fails earlier still, at adb install (Can't find service: package), so the app never launches. These are environment limits of driving a WebView headless, not feature regressions, and the suite command is cd zikzak_inappwebview/example && flutter test integration_test/<file>.dart -d <device>.

Sources: AGENTS.md, tdd-profile.md

Linux is the exception that gets real native coverage, because Dart tests cannot compile the WPE plugin or exercise its network and bridge paths. CI runs a two-architecture job (ubuntu-24.04 and ubuntu-24.04-arm) inside a digest-pinned debian:sid container that installs WPE WebKit, asserts a pkg-config --atleast-version=2.50 floor, drives the example’s native_navigation_test.dart under dbus-run-session + xvfb-run with the WebKit sandbox disabled for the container, then runs the compiled C++ tests via ctest and uploads the JSON result manifest as an artifact with if-no-files-found: error.

Sources: ci.yml, native_navigation_test.dart

Three non-flutter test gates complete the picture. scripts/grep_gate.sh is a structural assertion for the two-tier split: it fails if intelligence-layer identifiers (WebViewPool, CassetteEngine, RecipePort, …) appear anywhere in zikzak_inappwebview/lib/src outside a narrow carve-out for raw capture-event plumbing, and fails if zikzak_inappwebview_module/lib imports platform_interface directly. resolve-floor is a resolution guard: it stands up a minimal consumer app pinned to the declared Flutter floor (3.50.0) with equatable: ^3.0.0 and this checkout wired in through root-level dependency_overrides, then asserts from pubspec.lock that the packages resolved from path and that zuraffa resolved inside 7.x — a typo’d override would otherwise leave the job validating pub.dev forever.

Sources: grep_gate.sh, ci.yml

The dependency_overrides detail is a trap worth internalizing: a plain path: under dependencies: makes flutter analyze emit invalid_dependency, which is a warning, and warnings are fatal under the gate. Overrides apply to the whole graph, which is also what makes the build jobs compile this checkout rather than the published artifact.

Sources: AGENTS.md, ci.yml

The workflow is 21 job legs on every push to master and every PR into it, with fail-fast: false throughout so one broken package does not mask the others.

Job Legs What it proves
build-linux 2 (amd64, arm64) WPE plugin compiles; native navigation, cookies, JS; ctest
analyze 8 packages flutter analyze --no-fatal-infos per package
test 7 packages flutter test per package on ubuntu-latest
test-web 1 flutter test --platform chrome
resolve-floor 1 minimal consumer resolves on Flutter 3.50.0, from path
build-ios 1 (macos-15) iOS Swift compiles (Swift 6 arm) via the example app
build-macos 1 (macos-15) macOS Swift compiles; override-resolution assertion

Sources: ci.yml, AGENTS.md

Measured on master at 2026-10-17 the tree was green at 1028 test cases with 0 warnings anywhere, reproduced locally by a per-package flutter analyze --no-fatal-infos + flutter test --concurrency=2 sweep. Treat those counts as a snapshot that moves — the umbrella alone was 29 files / 269 passing tests, the platform interface 39 files / 309, macOS 19 / 156, iOS 17 / 113 — and re-measure rather than quoting.

Sources: AGENTS.md

Because GitHub Actions is billing-blocked on the private repos (runs end in ~3s with zero steps executed, so a red check carries no signal), scripts/local_ci.sh is the real gate. It is not a second copy of the workflow: it parses .github/workflows/* at run time, selects the workflow matching the simulated event, expands the matrix as a cross product, and executes jobs and steps in order — so editing the workflow changes the local run. It also states out loud what it cannot reproduce: the Linux platform, GitHub context expressions (skipped with the reason printed, never guessed), uses: actions (toolchain setups become version assertions against the local tool), container: images, and cargo cross-targets.

Sources: local_ci.sh, AGENTS.md

Terminal window
./scripts/local_ci.sh # every job of the pull_request workflow
./scripts/local_ci.sh --plan # print every step, run nothing
./scripts/local_ci.sh --job test # one job by id
./scripts/local_ci.sh --keep-going # do not stop at the first failure

Exit 0 means every executed step passed. A step that fails naming only gitignored or untracked local paths is reported as a LOCAL-ONLY failure rather than a CI failure, unless you pass --strict.

Sources: AGENTS.md, AGENTS.md

The natural progression from here is into the discipline that produces these tests — Spec-Kit Specification and TDD Workflow — followed by Continuous Integration, GYM Exercises, and Publishing for the release-side view of the same matrix. To understand what the tests are protecting, read Two-Tier Core/Module Split and the Grep Gate alongside the gate script, and The Platform Interface: The Contract Seam for why the fake-based acceptance tests are possible at all. For the layer that only a device can exercise, see Disposal Lifecycle and KeepAlive Patterns and Apple Native Layer (Swift and Swift Package Manager).