Overview
The SDK test suite is extensive:- 25,329+ test files in
tests/directory - 1.5+ million lines of test code
- 95,000+ individual assertions
- 476 supported configurations
Key Concepts
Test Runner
The test runner (test.py or test.dart) executes tests across configurations. It lives at pkg/test_runner.
Test Suites
Collections of test files, typically corresponding to top-level directories intests/:
language- Language feature testslib- Core library testsco19- Conformance tests
Directories with
_2 suffix contain pre-null-safety tests (legacy from Dart 1.0 to 2.0 migration).Configurations
A specific combination of tools and options, such as:- “Run on VM on Linux in debug mode”
- “Compile with DDC and run in Chrome”
- “Analyze using analyzer with asserts enabled”
tools/bots/test_matrix.json.
Test Outcomes
Expectation: What a human author says the tool should do (from test code comments) Outcome: The actual observed behavior when running the test Status: Previously recorded behavior from the results databaseRunning Tests Locally
Using test.dart (Recommended)
The modern entrypoint that reads status from the results database:Using test.py (Legacy)
The older entrypoint using status files:The
test.py approach is deprecated and may show spurious failures due to outdated status files.Finding Configurations
Use--find-configurations to discover available configurations:
-m, --mode- Release or debug mode-c, --compiler- Compiler to use (dart2js, dartdevc, etc.)-r, --runtime- Runtime environment (vm, chrome, d8, etc.)-a, --arch- Architecture (x64, arm64, etc.)-s, --system- OS (linux, macos, windows)
Local vs Bot Configurations
Run a bot configuration locally with a different platform config:-n(lowercase): Configuration for results lookup-N(uppercase): Configuration to run locally
Testing Different Components
VM Tests
dart2js Tests
Precompilation Tests
App Snapshot Tests
Writing Tests
Basic Tests
Simple tests use theexpect package:
Runtime Error Tests
Static Error Tests
Test compile-time errors with error expectation comments:Error Expectation Syntax
- Carets (
^) mark error location and length [analyzer]lines specify analyzer error codes[cfe]lines specify CFE error messages- Omit either for front-end-specific errors
Updating Static Error Tests
Automatically update error expectations:Viewing Test Results
Current Results App
View current test status with filtering: https://dart-current-results.web.app/Results Feed
See recent status changes and unapproved results: https://dart-ci.firebaseapp.com/Commit Queue and Bots
When you submit a code review:- Trybots run a subset of configurations on the commit queue
- Tests must “pass” (behavior unchanged from previous runs)
- Approve any intentional status changes
- After landing, all bots run the full test suite
- Address any failures by approving changes, reverting, or fixing
A test failure means the behavior CHANGED, not necessarily that it’s broken. When fixing bugs, status changes are expected and must be approved.