Expand description
Test command — run unit tests against the database.
Executes EXECUTE UNIT TEST statements attached to project objects
against a Materialize instance spun up in Docker. The pipeline:
- Load — Compile the project and optionally load/generate type metadata.
- Filter — Select tests matching the user’s filter pattern (supports
database.schema.object#test_namewith wildcards at any level). - Connect — Establish a database connection to the target environment.
- Execute — For each test: locate the target view, desugar the test into SQL, execute setup statements, run the assertion query, and classify the result.
- Report — Print pass/fail output and, when requested, produce a JUnit XML report.
§Outcome Classification
- Passed — Assertion query returned zero rows (no mismatches).
- Failed — Assertion query returned rows (missing or unexpected data) or a runtime error occurred during execution.
- ValidationFailed — Test definition is invalid (bad target, malformed
AT TIME, etc.). Tracked separately so summary output distinguishes broken definitions from runtime failures.
Modules§
Structs§
- Test
Filter 🔒 - Filter to select a subset of tests to run.
- Test
Result 🔒Entry - Per-test result captured during execution and used to build the JUnit report. Serializable so the full result set can be emitted structurally (e.g. for future machine-readable reporting).
- Test
Results 🔒 - Aggregated results of a test run. Acts as the canonical intermediate form from which the JUnit XML report is derived, and is kept serializable so the same shape can back a structured JSON report in the future.
- Test
Summary 🔒 - Aggregate pass/fail counts for the test run.
Enums§
- Execution
Failure 🔒 - Test
Outcome 🔒 - Final classification for a single test invocation.
- Test
Target 🔒 - Run unit tests against the database.
- Validation
Failure 🔒 - Pre-execution validation failure in a test definition.
Functions§
- extract_
assertion_ 🔒data - Extracts structured assertion data from failing query rows.
- format_
assertion_ 🔒rows - Formats failing assertion rows into a readable, ANSI-colored table for terminal output.
- format_
assertion_ 🔒rows_ for_ junit - Formats structured assertion data into plain-text for JUnit XML output.
- load_
or_ 🔒generate_ types_ cache - Load or generate type metadata needed for test execution.
- print_
summary 🔒 - Prints the test summary line showing pass/fail counts.
- print_
test_ 🔒outcome - Prints the complete status line and any detail output for a single test outcome.
- print_
test_ 🔒validation_ error - Renders validation failures in the standard test output format.
- run
- run_
single_ 🔒test - Executes one test case through validation, setup SQL, assertion query, and cleanup.
- run_
tests 🔒 - runtime_
client 🔒 - Creates an isolated runtime client for test execution.
- validate_
at_ 🔒time - Pre-validates optional
AT TIMEtest expressions againstmz_timestampcasting.