Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dart_test_filter

A clean, color-coded test output filter for dart test, flutter test, and flutter drive UI / integration tests. Suppresses noisy reporter and app logs and replaces them with a live progress line and clear failure details.

Features

  • Works with dart test, flutter test, and UI integration tests (flutter drive)
  • Live progress bar with completed/total count and percentage
  • Color-coded output: green for passed, yellow for skipped, red for failed
  • Inline failure details with error messages and stack traces
  • Clean summary banner at the end
  • ANSI color support detection (including Windows)
  • Exits with code 1 when any test fails
  • UI mode (--ui / auto-detect): parses [uitest] protocol lines and hides Dio/HTTP/socket noise
  • ASCII-safe output (default): strips multi-byte UTF-8 from printed output to avoid IDE terminal decode noise during long runs; use --unicode for emoji and raw Unicode

Requirements

  • Python 3.10+
  • Dart SDK or Flutter SDK

Installation

pipx (recommended)

pipx install git+https://github.com/Corkscrews/dart_test_filter.git

This installs dart-test-filter globally in an isolated environment. No venv activation needed.

From source

make install

This creates a .venv, installs the package and dev dependencies into it.

Usage

Unit tests (JSON reporter)

source .venv/bin/activate
dart test --reporter json | dart-test-filter
flutter test --reporter json | dart-test-filter

UI / integration tests ([uitest] protocol)

Emit structured lines from Dart (see UiTestLog in the host app), then:

flutter drive ... 2>&1 | dart-test-filter --ui

--ui is also auto-enabled when the first [uitest] line appears. Pass --all to keep raw drive/app logs alongside filtered progress.

Protocol:

[uitest] suite start|<id>|<label>|<expectedSteps>
[uitest] step start|<suiteId>|<stepId>|<label>
[uitest] step pass|<suiteId>|<stepId>
[uitest] step fail|<suiteId>|<stepId>|<message>
[uitest] suite done|<id>
[uitest] note|<suiteId>|<message>

flutter drive may prefix lines with flutter: ; the filter strips that.

Example UI output:

SUITE: Offline consultation (4 steps)
  -> Offline consultation / Scenario A: full offline
  [ok] Offline consultation / Scenario A: full offline
Running: 1/4 (25%) | Passed: 1

FAIL: Offline consultation / Scenario C: online then mid-drop
  pumpAndSettle timed out

==================================================
  4 steps: 1 passed, 0 skipped, 1 failed
==================================================

--ci

Pass --ci for CI-friendly output. Suppresses the live progress bar (which uses \r and doesn't render well in CI log viewers) and collapses verbose dependency-resolution output into a single line. Only failures and the final summary are printed.

flutter test --reporter json 2>&1 | dart-test-filter --ci
flutter drive ... 2>&1 | dart-test-filter --ui --ci

--report

Pass --report to write all errors and skipped tests to a timestamped log file:

dart test --reporter json | dart-test-filter --report
# creates 20260312_143022.log

Example unit-test output

Running: 42/50 (84%) | Passed: 40 | Skipped: 1 | Failed: 1

FAIL: subtract subtracts two numbers
  Expected: <6>
    Actual: <14.0>
  test/calculator_test.dart 27:7  main.<fn>.<fn>

==================================================
  50 tests: 48 passed, 1 skipped, 1 failed
==================================================

Development

make install          # create .venv and install package + dev deps
make test             # run all tests
make test-unit        # unit tests only (no Dart SDK needed)
make test-integration # end-to-end with dart test
make lint             # ruff check
make format           # ruff format
make clean            # remove .venv, caches, build artifacts

How It Works

JSON reporter (unit tests)

Event Action
group Extracts total expected test count
testStart Registers the test by ID
error Buffers error/stack trace for the test
testDone Updates counters, prints failures inline
done Prints the final summary banner

[uitest] protocol (UI tests)

Line Action
suite start Adds expected step count, prints suite header
step start / pass / fail Updates counters, progress, inline failures
note Always printed (even when noise is hidden)
Flutter EXCEPTION CAUGHT Captured and printed in filtered UI mode

Project Structure

src/dart_test_filter/
├── __init__.py        # Package exports and CLI entry point
├── __main__.py        # python -m support
└── filter.py          # TestFilter class and AnsiColors
tests/
├── conftest.py        # Shared fixtures
├── test_filter.py     # Unit tests (no Dart SDK needed)
├── test_ui_filter.py  # [uitest] protocol unit tests
└── test_integration.py # End-to-end with dart test
example/               # Minimal Dart project for integration tests

About

A clean, color-coded test output filter for `dart test` and `flutter test`.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages