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.
Project description
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(typicallytarget/run_results.json) - Source of truth: the
resultslist inside that file - Filtering: by default, only dbt tests are included (
unique_idstarts withtest.)
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 torun_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)
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
--inputpath. - If you only want dbt tests in ADO, do not pass
--include-models(default behavior already filters to tests).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dbt_to_junit-0.1.3.tar.gz.
File metadata
- Download URL: dbt_to_junit-0.1.3.tar.gz
- Upload date:
- Size: 134.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f9d7e7b91bc2a4c9fc6e2ff230e025e9c95d659a4d8d558fd618df09438d14c
|
|
| MD5 |
6236ad30fa4c0b04a67ff288e7f77279
|
|
| BLAKE2b-256 |
4c0fbe8d4af5357c33905401c7c55d2a1db4a811d280b7d996e6ddf201cc3710
|
File details
Details for the file dbt_to_junit-0.1.3-py3-none-any.whl.
File metadata
- Download URL: dbt_to_junit-0.1.3-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3557860d8b135073e7834850c8d27ac8de064d2d135e4a37b0827046b9d27f5
|
|
| MD5 |
767d4bc6c475c176081603e359075947
|
|
| BLAKE2b-256 |
f5a82c0a847252df24db0fc7dabcb89096758a2b82cbc8d8ba145cc96cdea1b6
|