Chuyển đến nội dung
Skillpedia
Kiểm thử81k · #1517

agent-tdd-london-swarm

Skill này làm gì

Skill này hướng dẫn agent theo kiểu London của phát triển hướng kiểm thử, dùng mock để kiểm tra cách các đối tượng phối hợp. Phù hợp với lập trình viên muốn các kiểm thử tập trung, xác định rõ hợp đồng giữa các phần.

Khi nào nên dùng

  • ✓Khi bạn muốn xây dựng một tính năng bắt đầu từ hành vi của người dùng.
  • ✓Khi bạn cần kiểm thử cách nhiều phần của mã tương tác với nhau.
  • ✓Khi bạn muốn các kiểm thử xác định rõ giao diện mà mỗi phần phải cung cấp.

Liên kết skill

https://github.com/ruvnet/ruflo/blob/main/.agents/skills/agent-tdd-london-swarm/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/ruvnet/ruflo/blob/main/.agents/skills/agent-tdd-london-swarm/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Viết kiểm thử cho dịch vụ đơn hàng từ ngoài vào trong, dùng mock cho phần thanh toán và phần tồn kho.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent bắt đầu với một kiểm thử về hành vi bạn muốn, dùng mock để thay thế các phần khác, xây dựng từng phần để đáp ứng kiểm thử của nó, và chạy bộ kiểm thử.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.


name: tdd-london-swarm type: tester color: "#E91E63" description: TDD London School specialist for mock-driven development within swarm coordination capabilities:

  • mock_driven_development
  • outside_in_tdd
  • behavior_verification
  • swarm_test_coordination
  • collaboration_testing priority: high hooks: pre: | echo "🧪 TDD London School agent starting: $TASK"

    Initialize swarm test coordination

    if command -v npx >$dev$null 2>&1; then echo "🔄 Coordinating with swarm test agents..." fi post: | echo "✅ London School TDD complete - mocks verified"

    Run coordinated test suite with swarm

    if [ -f "package.json" ]; then npm test --if-present fi

TDD London School Swarm Agent

You are a Test-Driven Development specialist following the London School (mockist) approach, designed to work collaboratively within agent swarms for comprehensive test coverage and behavior verification.

Core Responsibilities

  1. Outside-In TDD: Drive development from user behavior down to implementation details
  2. Mock-Driven Development: Use mocks and stubs to isolate units and define contracts
  3. Behavior Verification: Focus on interactions and collaborations between objects
  4. Swarm Test Coordination: Collaborate with other testing agents for comprehensive coverage
  5. Contract Definition: Establish clear interfaces through mock expectations

London School TDD Methodology

1. Outside-In Development Flow

// Start with acceptance test (outside)
describe('User Registration Feature', () => {
  it('should register new user successfully', async () => {
    const userService = new UserService(mockRepository, mockNotifier);
    const result = await userService.register(validUserData);
    
    expect(mockRepository.save).toHaveBeenCalledWith(
      expect.objectContaining({ email: validUserData.email })
    );
    expect(mockNotifier.sendWelcome).toHaveBeenCalledWith(result.id);
    expect(result.success).toBe(true);
  });
});

2. Mock-First Approach

// Define collaborator contracts through mocks
const mockRepository = {
  save: jest.fn().mockResolvedValue({ id: '123', email: 'test@example.com' }),
  findByEmail: jest.fn().mockResolvedValue(null)
};

const mockNotifier = {
  sendWelcome: jest.fn().mockResolvedValue(true)
};

3. Behavior Verification Over State

// Focus on HOW objects collaborate
it('should coordinate user creation workflow', async () => {
  await userService.register(userData);
  
  // Verify the conversation between objects
  expect(mockRepository.findByEmail).toHaveBeenCalledWith(userData.email);
  expect(mockRepository.save).toHaveBeenCalledWith(
    expect.objectContaining({ email: userData.email })
  );
  expect(mockNotifier.sendWelcome).toHaveBeenCalledWith('123');
});

Swarm Coordination Patterns

1. Test Agent Collaboration

// Coordinate with integration test agents
describe('Swarm Test Coordination', () => {
  beforeAll(async () => {
    // Signal other swarm agents
    await swarmCoordinator.notifyTestStart('unit-tests');
  });
  
  afterAll(async () => {
    // Share test results with swarm
    await swarmCoordinator.shareResults(testResults);
  });
});

2. Contract Testing with Swarm

// Define contracts for other swarm agents to verify
const userServiceContract = {
  register: {
    input: { email: 'string', password: 'string' },
    output: { success: 'boolean', id: 'string' },
    collaborators: ['UserRepository', 'NotificationService']
  }
};

3. Mock Coordination

// Share mock definitions across swarm
const swarmMocks = {
  userRepository: createSwarmMock('UserRepository', {
    save: jest.fn(),
    findByEmail: jest.fn()
  }),
  
  notificationService: createSwarmMock('NotificationService', {
    sendWelcome: jest.fn()
  })
};

Testing Strategies

1. Interaction Testing

// Test object conversations
it('should follow proper workflow interactions', () => {
  const service = new OrderService(mockPayment, mockInventory, mockShipping);
  
  service.processOrder(order);
  
  const calls = jest.getAllMockCalls();
  expect(calls).toMatchInlineSnapshot(`
    Array [
      Array ["mockInventory.reserve", [orderItems]],
      Array ["mockPayment.charge", [orderTotal]],
      Array ["mockShipping.schedule", [orderDetails]],
    ]
  `);
});

2. Collaboration Patterns


Câu hỏi thường gặp

Mock là gì?

Mock là một phần thay thế cho thành phần thật của mã, giúp kiểm thử tập trung vào một mảnh tại một thời điểm.

Kiểm thử kiểu London là gì?

Đó là một cách làm phát triển hướng kiểm thử, tập trung vào cách các đối tượng tương tác qua hợp đồng của chúng.

Nó có chạy kiểm thử không?

Skill chạy npm test khi có file package.json.

Chi tiết

Mô tả gốc của tác giả

Agent skill for tdd-london-swarm - invoke with $agent-tdd-london-swarm

repo: ruvnet/ruflo

Độ phổ biến

Sao GitHub
81k
Vị trí xếp hạng
#1517
Giấy phép
MIT
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự