Use Claude to Write Integration Tests for Your Service Layer
Unit tests verify logic in isolation. Integration tests verify that your service actually talks to the database, queue, and cache correctly — and they catch a different class of bugs entirely.
Write integration tests for UserService that test against the real database. Each
test should run in a transaction that rolls back after the test. Cover: creating a
user dispatches a welcome email to the queue, duplicate email throws a unique
constraint exception, and a soft-deleted user cannot log in.
Claude generates tests that use real connections to your database and queue in a safe way — wrapping each test in a transaction so there's no test data to clean up. It knows the idiomatic approach for your framework (database transactions in Laravel, test containers in Spring, pytest fixtures in Python).
Test the hard stuff — transactions:
Add an integration test that verifies a failed payment rolls back the order creation
in the same database transaction, leaving no orphaned records.
You can push further and ask Claude to generate tests that check for correct database index usage — connecting to a test database, running the query, and asserting it uses a covering index.
Integration tests take longer to run than unit tests but catch the bugs that make it to production.
Unit tests tell you the parts work. Integration tests tell you they work together.
Log in to leave a comment.
The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.
The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.
Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.