integration-testing
БесплатноБез исполняемых скриптовНе проверенUse when writing or improving integration tests that verify multiple components working together. Covers Testcontainers, ASP.NET WebApplicationFactory…
от onfire7777★ 17 звёзд на GitHubОб этом скилле
Integration Testing — Testing Multiple Units Working Together
Overview
Integration tests verify that multiple components work together correctly — services calling databases, HTTP clients hitting real APIs, message producers and consumers interacting. They provide the highest confidence-per-dollar in the Test Trophy model.
"Write tests. Not too many. Mostly integration." — Kent C. Dodds
When to Use Real Dependencies vs Mocks
| Use Real Dependencies | Use Mocks/Stubs |
|---|---|
| Database queries and transactions | Third-party APIs with rate limits |
| Message broker publish/subscribe | Payment gateways (use sandbox instead) |
| Cache read/write behavior | Email/SMS sending |
| File system operations | External auth providers |
| Service-to-service HTTP calls (in-process) | Services owned by other teams (use contract tests) |
Testcontainers
Testcontainers spins up real Docker containers for your test dependencies — databases, message brokers, caches, and more. Available for Java, .NET, Node.js, Python, and Go.
Node.js (Vitest + Testcontainers)
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
import { PostgreSqlContainer, StartedPostgreSqlContainer } from '@testcontainers/postgresql';
import { Pool } from 'pg';
import { UserRepository } from './user-repository';
describe('UserRepository', () => {
let container: StartedPostgreSqlContainer;
let pool: Pool;
let repo: UserRepository;
beforeAll(async () => {
container = await new PostgreSqlContainer('postgres:16-alpine')
.withDatabase('testdb')
.withUsername('test')
.withPassword('test')
.start();
pool = new Pool({ connectionString: container.getConnectionUri() });
// Run migrations
await pool.query(`
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
email TEXT UNIQUE NOT NULL,
created_at TIMESTAMPTZ DEFAULT NOW()
)
`);
repo = new UserRepository(pool);
}, 60_000); // Container startup can take time
afterAll(async () => {
await pool.end();
await container.stop();
});
it('should save and retrieve a user', async () => {
const user = await repo.create({ name: 'Alice', email: '[email protected]' });
const found = await repo.findById(user.id);
expect(found).toEqual(expect.objectContaining({
name: 'Alice',
email: '[email protected]',
}));
});
it('should throw on duplicate email', async () => {
await repo.create({ name: 'Bob', email: '[email protected]' });
await expect(
repo.create({ name: 'Bob2', email: '[email protected]' })
).rejects.toThrow(/unique/i);
});
it('should list users with pagination', async () => {
// Seed data
for (let i = 0; i < 15; i++) {
await repo.create({ name: `User ${i}`, email: `user${i}@example.com` });
}
const page1 = await repo.list({ limit: 10, offset: 0 });
const page2 = await repo.list({ limit: 10, offset: 10 });
expect(page1).toHaveLength(10);
expect(page2.length).toBeGreaterThanOrEqual(5);
});
});
C# (.NET + Testcontainers)
using Testcontainers.PostgreSql;
using Npgsql;
using Xunit;
public class UserRepositoryTests : IAsyncLifetime
{
private readonly PostgreSqlContainer _postgres = new PostgreSqlBuilder()
.WithImage("postgres:16-alpine")
.WithDatabase("testdb")
.WithUsername("test")
.WithPassword("test")
.Build();
private NpgsqlConnection _connection = null!;
private UserRepository _repo = null!;
public async Task InitializeAsync()
{
await _postgres.StartAsync();
_connection = new NpgsqlConnection(_postgres.GetConnectionString());
await _connection.OpenAsync();
// Run migrations
await using var cmd = new NpgsqlCommand(
"CREATE TABLE users (id SERIAL PRIMARY KEY, name TEXT NOT NULL, email TEXT UNIQUE NOT NULL)",
_connection);
await cmd.ExecuteNonQueryAsync();
_repo = new UserRepository(_connection);
}
public async Task DisposeAsync()
{
await _connection.DisposeAsync();
await _postgres.DisposeAsync();
}
[Fact]
public async Task Create_ValidUser_PersistsToDatabase()
{
var user = await _repo.CreateAsync(new CreateUserRequest("Alice", "[email protected]"));
var found = await _repo.FindByIdAsync(user.Id);
Assert.NotNull(found);
Assert.Equal("Alice", found.Name);
}
[Fact]
public async Task Create_DuplicateEmail_ThrowsException()
{
await _repo.CreateAsync(new CreateUserRequest("Bob", "[email protected]"));
await Assert.ThrowsAsync<PostgresException>(
() => _repo.CreateAsync(new CreateUserRequest("Bob2", "[email protected]")));
}
}
Java (JUnit 5 + Testcontainers)
import org.junit.jupiter.api.*;
import org.testconta
Установить integration-testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл integration-testing?
Use when writing or improving integration tests that verify multiple components working together. Covers Testcontainers, ASP.NET WebApplicationFactory, Supertest, pytest with real databases, Spring Boot testing, test database patterns, and CI/Docker-in-Docker strategies. USE FOR: integration tests, Testcontainers, WebApplicationFactory, testing with real databases, testing multi-component interactions, service integration tests DO NOT USE FOR: isolated function tests (use unit-testing), full browser tests (use e2e-testing), service boundary verification (use contract-testing)
Как установить скилл integration-testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл integration-testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic