x-unit-test-partial-interface

Design consumer-side minimal interfaces for unit testing external dependencies.

2|Updated Apr 12, 2026
One-click install
npx skills add https://github.com/pure-golang/level85 --skill x-unit-test-partial-interface
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: x-unit-test-partial-interface
Source: https://github.com/pure-golang/level85/tree/main/.agents/skills/x-unit-test-partial-interface
Command: npx skills add https://github.com/pure-golang/level85 --skill x-unit-test-partial-interface

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Skill helps you write unit tests with external dependencies without turning them into integration tests by capturing only the minimal consumer-side contract (or using callback aliases) needed for verification.

Core Features & Use Cases

  • Consumer-side minimal interface: define a small local interface next to the code under test using only methods you actually call.
  • Callback alias when interfaces are unnecessary: if the API already accepts a function, prefer a local callback alias instead of creating an interface just for mocking.
  • Mocking strategy via x-mockery: generate mocks for the chosen local interface and avoid mocking callback types through mockery.
  • Test shape guidance: choose between simple, table-driven, call-test, or suite.Suite based on setup/verify complexity.

Use case: a service depends on a storage adapter where only GetItem is needed for the unit scenario; extract a tiny interface (or callback) so you can test error mapping and returned entities with clean Arrange/Act/Assert.

Quick Start

Ask the AI to apply x-unit-test-partial-interface to my service method, and to propose the smallest consumer-side interface (or callback alias), plus a unit test structure (including Arrange/Act/Assert) that stays isolated from the real external adapter.

Frequently Asked Questions about x-unit-test-partial-interface

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

FAQPage Schema
How do I isolate unit tests from external dependencies in Go?

You isolate Go unit tests by extracting a consumer-side minimal interface that captures only the required dependency methods, keeping tests isolated from real external adapters while verifying error mapping and conditional expectations.

What is a callback alias and when should I use it instead of an interface for mocking?

A callback alias replaces a formal interface when an API already accepts a function. Use this local alias instead of creating an interface just for mocking to keep callback dependencies from being over-mocked.

Should I use mockery to mock callback types in Go unit tests?

No, you should avoid mocking callback types via mockery. Instead, generate mocks for chosen local consumer-side interfaces and use callback aliases for function-based dependencies to prevent over-mocking.

How do I structure a Go unit test with Arrange Act Assert for external adapters?

Structure Go unit tests by choosing between simple, table-driven, call-test, or suite.Suite shapes based on setup and verification complexity, then apply Arrange/Act/Assert to verify conditional expectations against the minimal interface.

Who should declare the interface when unit testing a service with external dependencies?

Interfaces must be declared by the consumer. This ensures imports remain within allowed project types, and the consumer captures only the minimal contract needed rather than mirroring the entire external dependency.