Skip to main content

dbt to JUnit XML

Convert dbt's target/run_results.json into a JUnit XML report so Azure DevOps (ADO) can display dbt test results in the Tests tab.

This tool is designed for CI: it reads the run results produced by dbt build, generates a single JUnit report, and writes it to a file that can be published by ADO.

What it reads

  • Input: dbt run_results.json (typically target/run_results.json)
  • Source of truth: the results list inside that file
  • Filtering: by default, only dbt tests are included (unique_id starts with test.)

What it writes

  • Output: a JUnit XML file (default: dbt-junit.xml)
  • Structure: one <testsuite> containing one <testcase> per dbt test

Install / run (local)

If you're using this repo with uv:

uv sync
uv run dbt-junit-xml --input target/run_results.json --output dbt-junit.xml

You can also run it directly with Python:

python -m src.main --input target/run_results.json --output dbt-junit.xml

CLI options

  • --input: path to run_results.json (default: target/run_results.json)
  • --output: output XML path (default: dbt-junit.xml)
  • --log-level: DEBUG|INFO|WARNING|ERROR (default: INFO)
  • --include-models: include non-test nodes as testcases (default: off)

Help

You can also run the following command to get some help in the terminal:

uv run dbt-junit-xml --help

or

python -m src.main --help

Response:

usage: dbt-junit-xml [-h] [--input INPUT] [--output OUTPUT] [--include-models] [--log-level LOG_LEVEL]

Convert dbt run_results.json to JUnit XML.

options:
  -h, --help            show this help message and exit
  --input INPUT         Path to dbt run_results.json (default: target/run_results.json)
  --output OUTPUT       Path to write JUnit XML (default: dbt-junit.xml)
  --include-models      Include model results as testcases (default: only dbt tests).
  --log-level LOG_LEVEL
                        Logging level (DEBUG, INFO, WARNING, ERROR). Default: INFO

Exit codes

  • 0: report generated and no failing dbt tests
  • 1: report generated and at least one dbt test failed/errored
  • 2: could not generate report (missing file, invalid JSON, unexpected format, etc.)

Azure DevOps pipeline example

Run dbt (which produces target/run_results.json), generate the JUnit XML, then publish it:

- script: |
    dbt build
    dbt-junit-xml --input target/run_results.json --output dbt-junit.xml
  displayName: "Run dbt and generate JUnit report"

- task: PublishTestResults@2
  displayName: "Publish dbt test results"
  inputs:
    testResultsFormat: "JUnit"
    testResultsFiles: "dbt-junit.xml"
    failTaskOnFailedTests: true

Notes / tips

  • If your pipeline working directory is not the dbt project root, pass an explicit --input path.
  • If you only want dbt tests in ADO, do not pass --include-models (default behavior already filters to tests).

Metadata

Release files for dbt-to-junit 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dbt-to-junit 0.2.0
File Size Uploaded
dbt_to_junit-0.2.0.tar.gz 134.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dbt-to-junit 0.2.0
File Interpreter ABI Platform
dbt_to_junit-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 141.6 kB

Release files / dbt_to_junit-0.2.0.tar.gz

Download URL dbt_to_junit-0.2.0.tar.gz
Size 134.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d961d78a9502e90b2875e6a165550c6c3aad0f84295c7fb0f47baf9d7240ebe9
BLAKE2b-256 checksum
How to use checksums
02dc9045556fb5bcd879c28e7c17f926d27f6ba90da3388e383dd693e434de4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / dbt_to_junit-0.2.0-py3-none-any.whl

Download URL dbt_to_junit-0.2.0-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c0096f17c8fb9fb2240ad9db8c9a1ae6f1ffe71675d8cc9ac1a4dfc7c46ed440
BLAKE2b-256 checksum
How to use checksums
bdc4876e186bd634a321f932e81e7e954e5a5729b10c7fa86308604ebe5d60d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page