go-unit-test-generator

Generate and update Go unit tests from git diffs with GoMock/testify.

31|4|Updated Aug 24, 2021
One-click install
npx skills add https://github.com/razorpay/trino-gateway --skill go-unit-test-generator
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-unit-test-generator
Source: https://github.com/razorpay/trino-gateway/tree/main/.agents/skills/go-unit-test-generator
Command: npx skills add https://github.com/razorpay/trino-gateway --skill go-unit-test-generator

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires jq, gh, git, go, and includes scripts (resource) and references (resource) components.

What problem does it solve?

The Go unit-test-generator automates end-to-end generation of unit tests for Go code changes on a feature branch. It analyzes diffs, creates table-driven tests with GoMock/testify, updates affected existing tests, runs locally until >95% coverage (max 5 iterations), commits, pushes, and monitors CI to deliver reliable test confidence.

Core Features & Use Cases

  • Phase-driven test generation and updates using production-grade patterns.
  • Generates table-driven tests with mocks, updates coverage, and ensures error-path coverage.
  • Use case: On a feature branch, automatically generate tests and push results to CI for validation.

Quick Start

Analyze your feature-branch changes to automatically generate, run, and push production-grade unit tests for changed Go code.

Frequently Asked Questions about go-unit-test-generator

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

FAQPage Schema
How do I automatically generate Go unit tests for changed code?

To automatically generate Go unit tests, this Skill analyzes your git diff to identify changed symbols and creates production-grade table-driven tests using GoMock and testify. It orchestrates local execution to enforce over 95% coverage before pushing the changes to CI.

How does table-driven test generation work with GoMock in a CI workflow?

Table-driven test generation with GoMock works by analyzing changed Go symbols from your feature branch diff and creating structured test cases with mock interfaces. The Skill runs these tests locally, iterating up to 5 times to achieve deterministic results, then commits and monitors them through CI handoff.

Do I need Go and jq installed to use this automated test generation workflow?

Yes, you need Go, jq, gh, and git installed to use this automated test generation workflow. These dependencies are required to analyze branch diffs, orchestrate local test execution, enforce coverage thresholds, and manage the CI handoff for reliable test validation.

Can I update existing Go tests automatically when modifying code on a feature branch?

Yes, you can update existing Go tests automatically when modifying code on a feature branch. The Skill analyzes your git diff to identify affected symbols and updates existing table-driven tests with GoMock and testify to maintain over 95% coverage for the changed code.

What is the best way to enforce high coverage for new Go code changes?

The best way to enforce high coverage for Go code changes is using a phase-driven generator that creates table-driven tests and iterates locally up to 5 times. This approach ensures error-path coverage and validates that over 95% of changed symbols are covered before CI integration.

Why does my automated Go test generation fail to reach 95% coverage?

Automated Go test generation might fail to reach 95% coverage if the changed symbols contain complex error paths that GoMock cannot easily mock. The Skill iterates up to 5 times locally to resolve this, but deterministic test results depend on the complexity of the diff and interface definitions.