brokle-testing

Guide pragmatic Go tests for Brokle service, domain, and handler layers.

3|2|Updated Sep 4, 2025
One-click install
npx skills add https://github.com/brokle-ai/brokle --skill brokle-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: brokle-testing
Source: https://github.com/brokle-ai/brokle/tree/main/.claude/skills/brokle-testing
Command: npx skills add https://github.com/brokle-ai/brokle --skill brokle-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides developers in writing pragmatic, high-value tests for the Brokle platform, focusing on complex business logic rather than trivial framework behavior. It saves time by optimizing testing efforts.

Core Features & Use Cases

  • Pragmatic Testing Philosophy: Clearly defines what to test (complex business logic, orchestration) and what to skip (simple CRUD, framework behavior).
  • Service Layer Test Pattern: Provides a detailed, table-driven test pattern with mock repositories and assertion best practices for Go services.
  • Integration Testing: Guides on setting up and running integration tests with real database dependencies for end-to-end verification.
  • Use Case: A developer has implemented a new complex billing calculation service. This skill helps them design effective unit tests that mock repository interactions and verify the business logic, ensuring correctness without over-testing.

Quick Start

I need to write a unit test for a new billing service that calculates subscription costs. Provide the table-driven test pattern, including how to mock repository dependencies and verify results.

Frequently Asked Questions about brokle-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write unit tests for Go services with mocking?

Unit tests for Go services use table-driven patterns with mocked repository dependencies. Mock the data layer to isolate business logic, verify calculations and orchestrations without database calls, and assert results against expected outcomes. This approach tests what matters while keeping tests fast and focused.

What should I test versus skip in Go backend testing?

Test complex business logic, multi-step orchestrations, and domain calculations. Skip trivial CRUD operations, simple framework behavior, and pass-through methods. Pragmatic testing prioritizes high-value assertions that catch real bugs, reducing test maintenance overhead while meeting coverage targets.

How do I set up integration tests with Go and real databases?

Integration tests run against actual database dependencies to verify end-to-end behavior. Set up a test database, seed required data, execute the full workflow, and assert results. Use this for critical paths after unit tests confirm individual layers work in isolation.

Can I use table-driven tests for Go service layer testing?

Table-driven tests are the standard pattern for Go service layer testing. Define test cases as rows with inputs, mocked outputs, and expected results. This structure scales test coverage efficiently, makes failures clear, and follows Go testing conventions across the Brokle platform.

Why mock repositories instead of testing against real databases?

Mocking repositories isolates business logic from data layer concerns, making unit tests faster, more reliable, and easier to debug. Mocks let you simulate error conditions and edge cases without database setup. Integration tests verify real database interactions separately, creating a balanced test pyramid.

How do I achieve target test coverage for Go backend services?

Target coverage by testing business logic, domain rules, and orchestration paths rather than line count. Use service layer tests with mocked dependencies to reach metrics efficiently. Focus assertions on value-producing decisions and error handling paths that impact system behavior.