Skip to main content

Test

This command executes unit tests for your project. To optimize performance, it automatically generates a bundle_test.dart file that aggregates all individual test files, allowing them to run in a single process per module.

morpheme test

Description

The test command is designed for modular architectures. It:

  1. Generates Bundles: Scans your test directories and creates test/bundle_test.dart files.
  2. Executes Tests: Runs the generated bundle or standard headers using flutter test.
  3. Aggregates Coverage: (Optional) Collects and merges LCOV coverage data from multiple modules.

Usage

Run All Tests

Executes unit tests for the entire project, including all features and shared modules.

morpheme test

Run Feature Tests

Run tests for a specific feature only.

morpheme test --feature profile

Run Page Tests

Run tests for a specific page within a feature.

morpheme test --feature profile --page edit_profile

Run with Coverage

Enable code coverage collection. The tool will merge coverage reports into a single coverage/merge_lcov.info file.

morpheme test --coverage

Custom Reporters

Output test results in JSON format or save them to a file (useful for CI/CD).

# Output JSON to stdout
morpheme test --reporter json

# Save JSON report to a file
morpheme test --file-reporter json:report.json

Options

morpheme test [options]

To see all available options and flags, run morpheme test --help.

Available Options

OptionAbbrDescription
--feature [name]-fTarget a specific feature for testing.
--page [name]-pTarget a specific page within a feature (requires -f).
--coverage-cEnable code coverage analysis and reporting.
--reporter [type]-rOutput format: compact, expanded, json, github, etc.
--file-reporterSave results to file. Format: <reporter>:<filepath>.
--morpheme-yaml [path]Path to a custom configuration file.