Makes one test in a model's test file, and keeps the answer that the test expects.
Use it to pin a number that you checked, so that a later change cannot move it without notice. The test goes in your own users/<email>/tests/<model>.sql, unless you add --shared or --workspace.
Examples
Terminal window
# Add a test from the Kater SQL in totals.sql, run it one time and keep the rows it returns
The test’s name, such as july_2026_spend_by_platform. No other test in the same file can have this name.
Options
Option
Description
--connection <name>
The connection, by its folder name under connections/. Leave it out when --workspace or --from-query names the connection, or when only one connection has the --model.
--model <model>
The shared semantic model or Kater dataset that the test checks, by its name or typed address, such as semantic.ad_reporting. With --from-query, give the model that the query’s workspace reads, or leave it out.
--sql-file <file>
A file of hand-written Kater SQL that reads the model. Give - to read the SQL from stdin.
--from-query <file>
A saved workspace query to keep as the test, by its path. Its workspace’s root must read one shared model whole, with optional filters at most. With --workspace, give one of that workspace’s own queries. Do not give --sql-file with it.
--query-name <name>
With --from-query, the query to keep, when the file holds more than one.
--picker-file <file>
A JSON file that asks the question as field picker selections: fields, conditions, group, order and limit. Give it in place of --sql-file, or with it. With both, the two must return the same answer.
--record
Runs the test one time and keeps the rows that it returns as the expected answer.
--refused
Compiles the SQL and keeps the code that the compiler refuses it with, such as not_additive_across. Use it to pin a rule of the model. The test is not added when the SQL compiles.
--same-as-native <file>
A file of read-only warehouse SQL, such as a query of a dbt mart. The test passes when the two answers are the same. Give --key with it.
--same-as-sql <file>
A file of Kater SQL over any shared model. The test passes when the two answers are the same. Give --key with it.
--key <column>
With --same-as-native or --same-as-sql, a column that pairs the rows of the two answers. You can give it more than one time.
--description <text>
What you checked the answer against, such as the Ads Manager export for July 2026.
--question <text>
The business question that the test answers, word for word as the model’s business_questions has it.
--draft
Marks the test as not checked yet. A draft runs and reports, but it does not count toward readiness. A draft can leave out the expected answer: its first run that returns rows records them.
--workspace <path>
A connection workspace, such as connections/snowflake_prod_connection/workspaces/ad_reporting. The test checks the workspace’s root and goes in the workspace’s tests/<root>.sql. Do not give --model or --shared with it.
--shared
Adds the test to the shared layer’s modeling/kater_objects/tests/<model>.sql, which everyone reads, in place of your own file. You need edit access to the shared models.
--as-of <date>
The day that the test takes as today, such as 2026-09-27. Then a relative condition, such as the last 7 complete days, reads fixed dates.
--inputs-file <file>
With --workspace, a JSON file with the root’s parameter values and filters: {"parameters": {...}, "filters": [...]}.
--given-file <file>
Makes the test a fixture. The JSON file gives the rows of each table that the model reads, as [{"table": NAME, "rows": [{COLUMN: value}]}]. Every other table is empty. Give --record with it.
--dry-run
Shows the test as it would go in the file, with its recorded answer, and saves nothing.
It also takes the global options--json, --kater-root, --scope and --help.
One expected answer
Give one of --record, --refused, --same-as-native or --same-as-sql. Only a draft can leave them all out. A test must read one closed range of the model’s dates, so that its answer does not move as data loads. Kater refuses a test that has no closed range, except a refused test or a fixture. See Every test pins a fixed set of rows.
An example SQL file
The examples above read this file. It asks for spend and clicks by platform and currency in July 2026: