> ## Documentation Index
> Fetch the complete documentation index at: https://docs.elementary-data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cloud tests or dbt tests

> When your environment supports both, choose whether a data test should run in Elementary Cloud or in your dbt project.

Elementary monitors two kinds of data tests:

* **dbt tests** are defined in your dbt project and run in your dbt pipeline. Elementary collects their results. You can add them in code or from the Elementary UI, which opens a pull request through your [code repository](https://docs.elementary-data.com/cloud/integrations/code-repo/connect-code-repo.md) integration.
* **Cloud tests** are defined in the Elementary UI and run by Elementary Cloud on their own schedule. [SQL data tests](https://docs.elementary-data.com/cloud/features/data-tests/sql-data-tests.md) and [custom SQL tests](https://docs.elementary-data.com/cloud/features/data-tests/custom-sql-tests.md) query your warehouse directly, through Elementary Cloud or an [Elementary Runtime](https://docs.elementary-data.com/cloud/features/elementary-runtime.md).

If your environment has a dbt project **and** [data access](https://docs.elementary-data.com/cloud/features/data-tests/sql-data-tests.md#where-the-queries-run) to its warehouse, you can add most data quality checks either way. Both kinds appear in the same test results, incidents, alerts, Catalog, and coverage views.

## Equivalent tests

| Check | Cloud test | dbt test |
| - | - | - |
| No duplicate values | [Uniqueness](https://docs.elementary-data.com/cloud/features/data-tests/sql-data-tests/uniqueness.md) | `unique`, `dbt_utils.unique_combination_of_columns` |
| No missing values | [Completeness](https://docs.elementary-data.com/cloud/features/data-tests/sql-data-tests/completeness.md) | `not_null` |
| Values follow a rule | [Validity](https://docs.elementary-data.com/cloud/features/data-tests/sql-data-tests/validity.md) | `accepted_values`, `dbt_expectations` tests for ranges, regex, and length |
| References exist in another table | [Relationship](https://docs.elementary-data.com/cloud/features/data-tests/sql-data-tests/relationship.md) | `relationships` |
| Custom business rule in SQL | [Custom SQL test](https://docs.elementary-data.com/cloud/features/data-tests/custom-sql-tests.md) | [Singular test](https://docs.elementary-data.com/data-tests/dbt/singular-tests.md) |
| Schema matches a baseline | [Data contract](https://docs.elementary-data.com/cloud/features/data-tests/data-contract-test.md) | [`schema_changes_from_baseline`](https://docs.elementary-data.com/data-tests/schema-tests/schema-changes-from-baseline) |

## How they compare

| | Cloud test | dbt test |
| - | - | - |
| Where it's defined | Elementary UI | Your dbt project's code |
| Pull request required | No | Yes |
| When it runs | Its own schedule in Elementary | With your dbt jobs, for example `dbt build` or `dbt test` |
| Can stop a pipeline | No. Results are reported after the data is loaded | Yes. With `dbt build`, a failing test can stop downstream models |
| Preview before saving | Runs against your warehouse and shows failing rows | Runs when the dbt job runs |
| Assets it can test | Any supported table in the environment, including tables outside dbt | dbt models, sources, seeds, and snapshots |
| Version control and review | Changes are recorded in the audit logs | Changes go through your code review |
| Warehouse credentials | The environment's connection, or a runtime in your network | Your dbt profile |
| Supported warehouses | Snowflake, Databricks, Redshift, and Postgres for SQL data tests | Any warehouse dbt supports |

## When to use cloud tests

Use a cloud test when:

* **You want coverage without a code change.** Analysts, data stewards, and business users can add and tune tests in the UI with no pull request or dbt knowledge.
* **The table isn't in dbt.** Cloud tests work on tables loaded by ingestion tools, other pipelines, or anything else in the warehouse.
* **The test needs its own schedule.** For example, check a source table hourly while your dbt jobs run daily, or check a table after an external load.
* **You want to see results before you commit.** The preview runs the test against your data and shows the failing rows before you save.
* **Warehouse credentials must stay in your network.** Run the tests through [Elementary Runtime](https://docs.elementary-data.com/cloud/features/elementary-runtime.md).

## When to use dbt tests

Use a dbt test when:

* **A failure should stop the pipeline.** Tests that run with `dbt build` can prevent bad data from reaching downstream models and dashboards.
* **Test configuration must be version-controlled.** The test lives next to the model, goes through code review, and is deployed with it.
* **The test must run with every model change**, including in CI on pull requests.
* **The check needs a test type or warehouse that cloud tests don't support**, such as ephemeral models, BigQuery, or tests from dbt packages.

## Defaults in the Elementary UI

When the environment has data access, Elementary suggests cloud tests first:

* In the add-test flow, the test picker starts filtered on **Elementary cloud**. Switch the filter to **dbt** to add a dbt test instead.
* For custom query tests, the selector next to the page title defaults to **Elementary Cloud (recommended)**. Choose **dbt** to open a pull request with a singular test. The dbt option requires a connected code repository.

## Avoid duplicates

If the same check exists as both a cloud test and a dbt test, **both run**. You get two results, possibly two alerts, and pay for both queries in your warehouse. When you move a check from dbt to the cloud, or the other way, remove the old test.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.