test-generator

Generate Go unit test skeletons from interface definitions.

85|13|Updated Jul 14, 2022
One-click install
npx skills add https://github.com/HyperDbg/gui --skill test-generator-hyperdbg
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-generator
Source: https://github.com/HyperDbg/gui/tree/main/.trae/skills/test-generator
Command: npx skills add https://github.com/HyperDbg/gui --skill test-generator-hyperdbg

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Go codebases with interface definitions often require boilerplate unit tests for each exported method. This skill automates generating those test skeletons, saving time and improving consistency.

Core Features & Use Cases

  • Generate test templates for all exported methods in a given interface.
  • Preserve the interface's method order to keep tests aligned with implementation.
  • Detect the package name from the input file's directory and place tests accordingly.

Quick Start

Run test-generator <input-file> <output-file> to create a Go test skeleton for the interface's exported methods and write the results to the specified output path.

Frequently Asked Questions about test-generator

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

FAQPage Schema
How do I generate Go unit test skeletons from interface definitions?

To generate Go unit test skeletons, provide an input Go source file and an output path. The tool parses interface definitions, filters for exported methods, and writes boilerplate tests to the specified file.

What is the best way to create boilerplate tests for exported methods in Go?

Creating boilerplate tests for exported methods is automated by parsing Go interface definitions and generating test skeletons. This preserves the original method order and infers the package name from the input directory.

Does the generated Go test skeleton preserve the original interface method order?

Yes, the generated Go test skeleton preserves the original interface method order. This ensures the produced boilerplate tests align directly with the sequence of exported methods in your implementation.

Can I use this to generate tests for unexported methods in a Go interface?

No, you cannot generate tests for unexported methods. The generation process specifically filters for exported methods within Go interface definitions to produce the test skeletons.

How does the tool determine the package name for the generated Go test file?

The tool determines the package name for the generated test file by inferring it from the input file's directory. This ensures the boilerplate tests are placed correctly within the same package context.