dbt Integration Testing with Testcontainers

VerifiedCaution

Set up and run integration tests using Testcontainers to verify warehouse adapter behavior against real database engines. Helps ensure correct handling of SQL dialect nuances, connection edge cases, and filesystem-dependent operations.

Sby Skills Guide Bot
TestingIntermediate
6/2/2026
Claude Code
#dbt#testcontainers#integration-testing#pytest#warehouse-adapter

Recommended for

Automated summary

Sets up and runs integration tests for dbt adapters using Testcontainers against real database engines in Docker containers.

Strengths

  • Verifies real database compatibility with SQL dialects and connection edge cases.
  • Isolates each test session in a clean container, ensuring reproducibility and automatic cleanup.
  • Uses specific image tags for consistent test results.
  • Optimizes performance with session or module scoped pytest fixtures.

Limitations

  • Requires Docker and a container runtime environment.
  • Container startup can slow down test execution.
  • Limited to database images supported by Testcontainers.
When to use it

When testing dbt adapters against real database engines to catch SQL dialect and connection issues.

When not to use it

If unit tests are sufficient or Docker is not available in the test environment.

Security analysis

Caution
Quality score90/100

The skill describes patterns for integration testing using Docker containers through testcontainers. While the content is legitimate, it involves container orchestration which carries inherent risks if not properly scoped. The skill itself does not contain destructive or exfiltrating commands, but Docker usage warrants caution.

Findings
  • •Involves management of Docker containers via testcontainers, which is a powerful tool that could be misused if instructions are extended arbitrarily.
How this analysis is made

Examples

Integration test for a new Postgres adapter
Set up integration tests for a new Postgres dbt adapter using Testcontainers, including a pytest fixture that starts a Postgres container and a test that verifies table creation and data insertion.
Filesystem test with DuckDB
Write a pytest fixture that starts a DuckDB container for testing filesystem-dependent operations in a dbt adapter, and add a test that checks that reading and writing CSV files works correctly.
BigQuery adapter integration test
Create an integration test for a BigQuery adapter using Testcontainers, testing partition extraction and query execution against a real BigQuery emulator or container.

name: dbt-helpers-integration-testcontainers description: Set up and run integration tests using Testcontainers. Use when testing warehouse adapters against real database engines or verifying filesystem-dependent operations.

dbt-helpers-integration-testcontainers

Purpose

To verify that our adapters work correctly against real infrastructure, ensuring that SQL dialect nuances, connection edge cases, and filesystem behaviors are correctly handled.

Core Principles

  1. Isolation: Each test session should have its own clean container instance.
  2. Reproducibility: Use specific image tags (e.g., duckdb:latest, postgres:15) to ensure consistent results.
  3. Efficiency: Use pytest fixtures with session or module scope where appropriate to minimize container startup overhead.

Patterns

1. Database Fixture

@pytest.fixture(scope="session")
def duckdb_container():
    with DuckDBContainer("duckdb/duckdb:latest") as duckdb:
        yield duckdb

@pytest.fixture
def catalog_client(duckdb_container):
    return DuckDBCatalogClient(connection_url=duckdb_container.get_connection_url())

2. Cleanup

Always ensure containers are stopped and resources are cleaned up using context managers or yield fixtures.

Instructions

When writing integration tests

  1. Locate tests in src/<package>/tests/integration/.
  2. Use testcontainers-python for managing Docker instances.
  3. Verify the adapter's behavior against the real engine (e.g., check that BQ partition info is correctly extracted).

When implementing a new warehouse adapter

  1. Create a corresponding integration test in the plugin package.
  2. Test both "happy path" and common failure modes (e.g., table not found, permission denied).

References

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/dbt-integration-testing-with-testcontainers-mm78noe3/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/dbt-integration-testing-with-testcontainers-mm78noe3' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/dbt-integration-testing-with-testcontainers-mm78noe3/download' --output '.skill-downloads/dbt-integration-testing-with-testcontainers-mm78noe3/SKILL.md.part' && mv '.skill-downloads/dbt-integration-testing-with-testcontainers-mm78noe3/SKILL.md.part' '.skill-downloads/dbt-integration-testing-with-testcontainers-mm78noe3/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/dbt-integration-testing-with-testcontainers-mm78noe3/SKILL.md' && test -s '.skill-downloads/dbt-integration-testing-with-testcontainers-mm78noe3/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/dbt-helpers-integration-testcontainers' && cp -R '.skill-downloads/dbt-integration-testing-with-testcontainers-mm78noe3' '.claude/skills/dbt-helpers-integration-testcontainers'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/dbt-integration-testing-with-testcontainers-mm78noe3'

openskills read 'dbt-integration-testing-with-testcontainers-mm78noe3'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/dbt-integration-testing-with-testcontainers-mm78noe3/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills