Changelog
All notable changes are listed here, newest first. The format follows Keep a Changelog, and versions follow Semantic Versioning; before 1.0.0, a minor version may change the spec format.
[Unreleased]
Section titled “[Unreleased]”Changed
Section titled “Changed”- The sample project runs on Postgres as well as duckdb (a CI job runs it against a Postgres
container), with a case for each database where the result differs: two integers divide to
2.5on duckdb and to2on Postgres.cents_to_dollarsof the sample divides by100.0, so that it gives the same on both.
adapterson a case:adapters: [duckdb]limits a case to some adapters (thetypeof the target the run uses). On another it is skipped and said so (SKIP ..., andN skippedin the summary), which is not a failure. For a macro whose result depends on the database, such as10 / 4, which is2.5on duckdb and2on Postgres. Part of #88 (tags are not done).
- On Postgres, the drop of the relations that a case made failed (
Tried to commit transaction ..., but it does not have one open!) and the tool said that they might be left in the warehouse, which they were not (a temporary table goes with its connection). The drop now runs in a transaction, as dbt’sget_drop_sqlstatement, so that the commit has something to commit. Found by running the sample on Postgres (#116).
[0.2.0] - 2026-11-26
Section titled “[0.2.0] - 2026-11-26”Test more kinds of dbt macros: ones that read a model (ref, source), ones that write to tables,
and ones that return text or a statement. The models the tool generates are named _dmt_… now.
Changed
Section titled “Changed”-
The models that the tool generates are named
_dmt_<spec>_<macro>_<case>(for dbt macro test), where 0.1.0 named them_mt_<spec>_<macro>_<case>. Not an interface, but dbt prints the names in the output of a run, so they are seen. (The relations that a case makes, and the macro that drops them, are new in this release and have_dmt_from the start.) -
The
Documentationlink of the package is the documentation site, not the spec reference on GitHub.
-
A documentation site, https://hirofumitsuda.github.io/dbt-macro-test/: a guide of what to write for each kind of macro (every example in it runs in CI), the spec reference, the design and the changelog. The README has a table of the same kinds that points to it.
-
run: execute: a macro that returns the text of a statement, such asdbt.get_merge_sql, has that statement run by the tool (run_query), andexpect.queryshows what it did to the relations of the case. Without it the text is dropped, as before. Only duckdb has been tried. -
given.inputs: a macro that callsref()orsource()itself (dbt_utils.staron a model,basic_aggregationover rows) is given the rows it is to see, asrowsor aselect. The tool writes a stand-in for each node, which is never built, and hands the rows to dbt as a select, since for rows written as mappings dbt asks the warehouse for the columns of the upstream relation. No real data is read. A string with a quote, a backslash or Jinja is written withsql. Arefthat no case gives is said to belong undergiven.inputs. The rows are seen by the finalselectonly, not by a statement the macro runs by itself (run_query). Only duckdb has been tried. -
output: text: a macro that returns text that is not SQL (a slug such asdbt_utils.slugify, the text of amerge) is compared as text. The text is returned as one string, with a single quote escaped by dbt’s own macro and the blank space at both ends dropped. Only duckdb has been tried. -
setup.relationsandexpect.query: a macro that runs statements itself (an upsert, a delete), or that reads a relation, is tested with relations that the tool makes for the case (fromrowsor aselect) and by the rows a query returns afterwards. The tool makes them as temporary relations with dbt’s ownmake_temp_relationandcreate_table_as, so it has no code for any adapter, and drops them after the tests (dbt’sdrop_relation_if_exists, by arun-operation), which matters on adapters whose temporary relation is not dropped with the connection. A real write, with nothing that asks first: the spec reference says so, and what “temporary” is on each adapter. Only duckdb has been tried.
[0.1.0] - 2026-11-25
Section titled “[0.1.0] - 2026-11-25”The first release. Test a dbt macro like a function: call it with the arguments you choose, say what it should return in a few lines of YAML, and run it on your machine or in CI, as dbt’s own unit tests.
dbt-macro-test run: a spec in YAML undermacro_test/is turned into throwaway models and dbt’s native unit tests, which dbt runs; the output and the diff of a failure are dbt’s own.- Zero-config project discovery, and the project’s
vars,dispatch,macro-pathsand packages carried over (installed packages are used as they are, otherwisedbt depsruns). - Arguments are given by name and checked against the macro’s declaration before dbt runs;
type: jinjawrites an expression, such as aRelation. output: a single expression (the default),columns(aliased or several), orquery(a wholeselect).expect: rows (a list of mappings, orformat: csv/sql), afixturefile, anerror, and awarningtogether with rows.overridesof macros,varsandenv_varsfor a case, passed to dbt’s own unit tests.--select,--list,--target,--profiles-dir,--project-dir,--keep-generated,--verbose; exit code 0 (passed), 1 (a case failed or errored), 2 (could not be run).- dbt-core 1.8 and later (below 2) on Python 3.11 and later; the suite runs in CI on Linux and Windows, on the newest dbt-core and on 1.8. Only duckdb has been tried.
Not yet
Section titled “Not yet”ref / source, text that is not SQL, DML, generic tests, dbt Fusion and adapters other than
duckdb; the README lists them with their issues.