write-tests

Generate unit and integration tests for Go microservices using testify and mockgen.

Updated Feb 10, 2026
One-click install
npx skills add https://github.com/vesviet/microservices-agent-skills --skill write-tests-vesviet
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-tests
Source: https://github.com/vesviet/microservices-agent-skills/tree/main/skills/write-tests
Command: npx skills add https://github.com/vesviet/microservices-agent-skills --skill write-tests-vesviet

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill ensures your microservice code is thoroughly tested, catching bugs early and maintaining code quality through established testing patterns.

Core Features & Use Cases

  • Unit Testing: Write tests for business logic in the biz layer.
  • Integration Testing: Create tests for service interactions and event handlers.
  • Mocking: Utilize mockgen or testify/mock for dependency simulation.
  • Use Case: After adding a new API endpoint, use this Skill to write comprehensive unit tests covering success, error, and edge cases, ensuring the new functionality works as expected.

Quick Start

Use the write-tests skill to add unit tests for the new order creation logic in the internal/biz/order package.

Frequently Asked Questions about write-tests

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

FAQPage Schema
How do I write table-driven unit tests for Go microservices?

Table-driven unit tests for Go microservices are generated by structuring test cases in data slices and iterating over them. This covers success, error, and edge cases for the biz layer.

How do I generate mocks with mockgen for Go integration testing?

Mocks for Go integration testing are generated using mockgen to simulate dependencies. This isolates and tests service interactions and consumer handlers without relying on live external services.

Can I use testify for mocking in Go biz layer unit tests?

Yes, testify is used for mocking in Go biz layer unit tests. It simulates dependency behavior, ensuring business logic tests are robust and isolated from external components.

What is the best way to test consumer handlers in Go microservices?

Testing consumer handlers in Go microservices is best done through integration tests. This verifies service interactions and event handling logic by utilizing mockgen-generated mocks for external dependencies.

Does writing Go unit tests require strict testing conventions and documentation updates?

Yes, writing Go unit tests requires adherence to strict testing conventions and documentation updates. This maintains code quality and ensures consistent testing patterns across the microservice architecture.