Testing

zero-native provides headless testing tools for bridge and lifecycle coverage without a GUI, plus automation-based integration tests.

TestHarness

TestHarness provides a headless test driver using NullPlatform and a BufferSink for capturing trace records:

var harness: zero_native.TestHarness = undefined;
harness.init(.{});

The harness provides a pre-configured runtime with NullPlatform and a trace sink that captures records in memory. Use it to test bridge handlers, lifecycle events, and command dispatch.

TestHarness is the same mechanism used by the framework's own test suite to verify bridge policy enforcement, window management, and lifecycle correctness.

Headless tests

The default test suite does not require a window server:

zig build test
zig build test-desktop
zig build test-platform-info

Bridge and IPC coverage lives in the headless desktop tests: they inject platform bridge events, exercise command policy and handlers, and assert the platform response without launching a WebView.

WebView smoke tests

WebView smoke coverage is a separate macOS integration step using Automation:

zig build test-webview-smoke -Dplatform=macos
zig build test-webview-cef-smoke -Dplatform=macos -Dweb-engine=chromium

This step:

  1. Starts the system WebView example with automation and the JS bridge enabled
  2. Waits for a published automation snapshot (zero-native automate wait)
  3. Verifies main window/source metadata (zero-native automate snapshot)
  4. Sends a native.ping request through zero-native automate bridge
  5. Verifies the response

The CEF smoke step additionally requires a local CEF layout or -Dcef-auto-install=true; it exercises native.ping and JS window create/list/focus/close through the automation bridge. These steps are intentionally opt-in because they need a GUI-capable macOS session.

NullPlatform

NullPlatform is a headless platform stub that records loaded sources and dispatched events without creating real windows. Use it in tests and with EmbeddedApp:

var null_platform = zero_native.NullPlatform.init(.{});
var runtime = zero_native.Runtime.init(.{
    .platform = null_platform.platform(),
});