On this page
Kater CLI Build and check test
kater test generate
Writes a starting set of draft tests for a shared model.
Each test runs one time on the warehouse and goes in your own test file as a draft. Then you check each draft, and mark it with kater test update --checked.
Examples
# Write five draft tests for the shared ad_reporting model, in your own test filekater test generate --model semantic.ad_reporting# Print the plan, and run and write nothingkater test generate --model semantic.ad_reporting --dry-run# Write 12 tests to the shared layer's test filekater test generate --model semantic.ad_reporting --count 12 --shared# Also write a test for each business question that no test answers yetkater test generate --model semantic.ad_reporting --from-questions# Write the test of one business question onlykater test generate --model semantic.ad_reporting --question "Which accounts contribute the most spend, clicks, and impressions?"Options
It also takes the global options --json, --kater-root, --scope and --help.
What it writes
- Five shapes first. By default, it writes one test of each shape: field picker to rows, field picker and Kater SQL to rows, Kater SQL to refused, field picker with operations to rows, and field picker to the same answer as native SQL. It does not write a shape again that the file has already.
- More coverage with
--count. Each test after the first five covers more of what no test covers yet: a measure, a grain, a kind of dimension, an operation family or a rule. - No native SQL. Kater never writes native SQL. The
same_astest reports that it has no answer until you write its native side. - One date range. Every test reads the same closed range of the model’s date field. See
--window. - Failures are not written. A test that fails is reported, and Kater leaves it out of the file.
- The same tests each time. On a model that did not change, a second run writes nothing that it wrote before.
- Business questions. A question that the model’s fields cannot answer is reported, not written. A question that the file answers already is skipped.
What it prints
The first line gives the date range and how many tests it plans, or what it wrote to which file. Then each test has one line: its number, its shape and what it asks. A test that the file has already is marked (in the file). After that come the tests that it did not write and why, and what to check before you accept a draft. The last line names what no test covers yet, and the --count that covers it.