# Running dbt unit tests in CI/CD

**URL:** <https://discourse.getdbt.com/t/running-dbt-unit-tests-in-ci-cd/13390>\
**Category:** Help\
**Created:** [May 16, 2024, 8:31am UTC](https://discourse.getdbt.com/t/running-dbt-unit-tests-in-ci-cd/13390 "2024-05-16T08:31:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubenhelsloot](https://avatars.discourse-cdn.com/v4/letter/r/0ea827/32.png) [@rubenhelsloot](https://discourse.getdbt.com/u/rubenhelsloot)\
**Post date:** [May 16, 2024, 8:31am UTC](https://discourse.getdbt.com/t/running-dbt-unit-tests-in-ci-cd/13390/1 "2024-05-16T08:31:34Z")

</div>

## The problem I’m having

I’m trying to run the new unit tests feature as part of my CI/CD pipeline, as you would do in software engineering. However, the tests are failing with the error

```auto
Not able to get columns for unit test 'projects' from relation "dwh"."marts"."projects"

```

Clearly the test database that is spun up inside the CI/CD pipeline has no knowledge of how the model’s upstream sources are structured.

## The context of why I’m trying to do this

I was hoping that the unit tests feature would allow me to introduce more software engineering best practices into the team, and we would only merge thoroughly tested models. Maybe unit tests are not 1-to-1 comparable between the software and data engineering paradigms

## What I’ve already tried

I could work around it by using the `sql` format for all data sources, but that makes it much more difficult to maintain. I guess I could try to download the `manifest.json` from the main branch, but this would have the issue that my PR has obviously changed the models, so the `manifest.json` would risk being out of date.

Has anyone run into this issue? Or does anyone have an idea on the best practices for setting up unit tests / CI/CD in dbt?

---

<div class="post-metadata">

**Author:** ![porh](https://avatars.discourse-cdn.com/v4/letter/p/f6c823/32.png) [@porh](https://discourse.getdbt.com/u/porh)\
**Post date:** [November 22, 2024, 8:31pm UTC](https://discourse.getdbt.com/t/running-dbt-unit-tests-in-ci-cd/13390/2 "2024-11-22T20:31:54Z")

</div>

I believe you are using different profile (target) in CI/CD vs Production.  
Option1  
You need to have to build model that unit test depending on in CICD as well before running unit test.  
Option2  
Using --defer when running unit test so dbt will use production model instead
