testdrive 0.1.0
testdrive: ^0.1.0 copied to clipboard
Flutter SDK for TestDeck. Captures HTTP, logs, navigation, and exceptions from debug builds.
TestDrive Changelog #
0.1.0 #
Initial release.
Capture #
- HTTP via
HttpOverrides— everydart:ioHttpClientis wrapped: method, URL, headers, request body, response status/headers/body, and duration. Capture is pre-TLS, so cert-pinned endpoints work. - Logs —
debugPrintis wrapped automatically;TestDrive.log(message, level:, tag:, payload:, error:, stack:)for explicit structured entries;TestDrive.developerLog(...)as a drop-in fordart:developer.log(forwards to the real call and maps the integer level +nameto aLogLevel/tag). - Navigation —
TestDrive.navigator()is a drop-inNavigatorObservercapturing push / pop / replace / remove with route names and arguments. - Errors —
FlutterError.onErrorandPlatformDispatcher.instance.onErrorare chained so Dart exceptions surface in the TestDeck desktop Errors tab; previous handlers still fire.
Transport #
- NDJSON-over-TCP to
127.0.0.1:9876(configurable), with a hello handshake carrying a wire-protocol version for forward compatibility. - 128-event reconnect buffer with full-jitter exponential backoff (1s → 30s cap) — the app is never blocked when the desktop isn't running.
- Rate limiter — a default 200 events/s cap (configurable via
maxEventsPerSecond,0to disable) protects the transport from adebugPrintflood.
Robustness #
- Encode-safe emit — non-encodable events (e.g. a
payloadholding a non-JSON value) are dropped at emit time and never buffered, so they can't wedge the queue; an encode failure never tears down a healthy socket. - No "pending forever" — response emission fires on the first of stream done, error, or subscription cancel, so requests never stick in a pending state in the desktop.
- Size-capped bodies — a stream tee captures up to 1 MB (configurable) without ever disturbing the app's own stream consumers.
- Honest stack traces — log entries use the attached error's own stack (or an explicit one), never substituting TestDrive's own frames.
- Stack cap — exception stacks are capped at 64 KB with a sentinel.
- Non-JSON nav args fall back to the runtime type name instead of crashing the host app.
detach()restores all previously installed globals.
Zero dependencies #
- Depends only on Dart SDK libraries plus Flutter.
Example app #
- Minimal example wiring
TestDrive.init()with HTTP capture, structured logs,developerLog, and aNavigatorObserver.
Platform support #
- Android: transport via
adb reverse(TCP loopback) - Web: not supported (
dart:ioHttpOverridesis unavailable on TestDrive Web)