Integration testing

From kid-sid/codex-spellbook · View interactive version

Integration testing is an AI agent skill from the GitHub repository kid-sid/codex-spellbook. Integration testing patterns for database state, API contracts, service boundaries, and component wiring. Use when testing how multiple parts of a system work together without mocks.

How to use this skill

Skill file

Integration Testing

Verify the interaction between components, data stores, and external services to ensure contract correctness and state integrity.

When to Activate

Testing Layers

| Level | Isolation | Speed | Confidence |

| --- | --- | --- | --- |

| Unit | Pure functions, mocked collaborators | Fastest | Low (Logic only) |

| Integration | Real database, real network clients | Medium | Medium (Contracts + State) |

| E2E | Real browser, full environment | Slowest | High (User journey) |

Database Integration

| Strategy | When to use | Rule |

| --- | --- | --- |

| Per-test Transaction | Standard relational DB tests | Wrap in begin, then rollback on teardown |

| Unique Fixtures | Parallel tests or non-transactional DBs | Use UUIDs/Random prefixes forทุก record |

| Truncation | Between suites or for dirty state | Truncate only the tables used |

BAD

def test_get_user_orders():
    # Relies on order ID 1 existing from previous test
    orders = get_user_orders(user_id=1)
    assert len(orders) == 1

GOOD

def test_get_user_orders(db_session, user_factory, order_factory):
    user = user_factory.create()
    order_factory.create(user_id=user.id)

    orders = get_user_orders(user_id=user.id)
    assert len(orders) == 1

API Boundaries

| Concern | Strategy |

| --- | --- |

| HTTP Clients | Use WireMock or Prism instead of mocking the client class |

| Message Brokers | Use a real containerized instance (Testcontainers) |

| File Storage | Use a local filesystem fake or MinIO |

Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.