一键导入
testing-patterns
Reference for analytics development testing patterns including unit tests, data quality tests, integration tests, and QA standards
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Reference for analytics development testing patterns including unit tests, data quality tests, integration tests, and QA standards
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Generate comprehensive PR descriptions from project context and git changes
Framework for when to use Skills, Agents, or Patterns for organizing knowledge in the ADLC platform with decision criteria and migration strategies
Generate dbt model boilerplate with tests, documentation, and best practices
Validate documentation completeness and quality before project completion
Initialize new ADLC project with standard directory structure, documentation templates, and git branch
Complete reference for MCP tool integration across specialist and role agents including server inventory, tool recommendations, and security protocols
| name | testing-patterns |
| description | Reference for analytics development testing patterns including unit tests, data quality tests, integration tests, and QA standards |
| user-invocable | false |
Following the Analytics Development Lifecycle testing approach:
Purpose: Logic testing within individual models
Patterns:
Example dbt Tests:
# Test specific column logic
- name: revenue
tests:
- not_null
- dbt_utils.expression_is_true:
expression: ">= 0"
Purpose: Data quality and conformance validation
Patterns:
Example dbt Tests:
# Data quality tests
tests:
- unique:
column_name: customer_id
- not_null:
column_name: order_date
- relationships:
to: ref('dim_customers')
field: customer_id
Purpose: Cross-system and end-to-end validation
Patterns:
Example dbt Tests:
# Cross-system validation
- name: reconciliation_test
tests:
- dbt_utils.recency:
datepart: day
field: created_at
interval: 1
What to Test:
Pattern:
-- Validate schema structure
SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'target_table'
AND column_name NOT IN (expected_columns)
When to Use:
What to Test:
Pattern:
-- Validate business metric
WITH actual AS (
SELECT SUM(revenue) as total_revenue
FROM {{ ref('fct_sales') }}
WHERE date = '2024-01-01'
),
expected AS (
SELECT 1000000 as total_revenue -- Known good value
)
SELECT *
FROM actual
CROSS JOIN expected
WHERE ABS(actual.total_revenue - expected.total_revenue) > 100
When to Use:
What to Test:
Pattern:
-- Monitor query performance
SELECT
query_text,
execution_time,
rows_produced,
bytes_scanned
FROM snowflake.account_usage.query_history
WHERE query_text ILIKE '%model_name%'
AND execution_time > 60000 -- Over 1 minute
ORDER BY execution_time DESC
When to Use:
What to Test:
Pattern:
-- Source to target reconciliation
WITH source_counts AS (
SELECT COUNT(*) as source_count
FROM source_system.orders
WHERE order_date = CURRENT_DATE - 1
),
target_counts AS (
SELECT COUNT(*) as target_count
FROM {{ ref('stg_orders') }}
WHERE order_date = CURRENT_DATE - 1
)
SELECT *
FROM source_counts
CROSS JOIN target_counts
WHERE source_count != target_count
When to Use:
# ADLC-aligned testing workflow
# 1. Run all test types for specific model
dbt test --select <model_name>
# 2. Execute model implementation
dbt run --select <model_name>
# 3. Validate results and store failures for investigation
dbt test --select <model_name> --store-failures
# 4. Run specific test type
dbt test --select test_type:generic # Built-in tests
dbt test --select test_type:singular # Custom SQL tests
# 5. Test entire model lineage
dbt test --select <model_name>+ # Downstream
dbt test --select +<model_name> # Upstream
dbt test --select +<model_name>+ # Full lineage
# Test incremental models efficiently
# 1. Full refresh for validation
dbt run --select <model_name> --full-refresh
# 2. Test full-refreshed data
dbt test --select <model_name>
# 3. Run incremental update
dbt run --select <model_name>
# 4. Validate incremental logic
dbt test --select <model_name> --store-failures
# Continuous integration testing
# 1. Test only modified models and downstream
dbt test --select state:modified+
# 2. Slim CI: test changes only
dbt test --select state:modified+ --defer --state ./prod-manifest
# 3. Full regression test
dbt test --exclude tag:slow
CRITICAL: "It loads" is NOT testing
Minimum Testing Requirements:
- [ ] Dashboard/page loads successfully
- [ ] All navigation elements work
- [ ] Filters apply correctly and update data
- [ ] Buttons trigger expected actions
- [ ] Forms validate input properly
- [ ] Error messages display appropriately
- [ ] Data refreshes when expected
- [ ] Loading states show properly
- [ ] Mobile/responsive layout works
- [ ] Accessibility standards met
- [ ] Source data ingested completely
- [ ] Transformations produce expected results
- [ ] Data quality tests pass
- [ ] Business metrics reconcile
- [ ] Performance acceptable
- [ ] Error handling works correctly
- [ ] Logging captures key events
- [ ] Monitoring alerts configured
- [ ] Documentation updated
- [ ] Stakeholders can access data
Is this a model change?
├─ Yes → dbt test --select <model>+
│ └─ Failures? → dbt test --store-failures → Investigate
├─ No → Is this a UI change?
│ ├─ Yes → qa-coordinator (hands-on testing)
│ │ └─ Screenshot capture + findings doc
│ └─ No → Is this a pipeline change?
│ ├─ Yes → Integration tests + reconciliation
│ └─ No → Is this infrastructure?
│ └─ Yes → Performance tests + monitoring
All code changes must meet these standards:
Automated Tests:
Manual QA:
Performance Validation:
Documentation:
Stakeholder Validation:
When documenting testing discoveries:
PATTERN: Reusable testing approachesSOLUTION: Specific test implementationsERROR-FIX: Test failures and resolutionsARCHITECTURE: Testing strategy decisionsINTEGRATION: Cross-system test coordination