testing-go-code

Execute Go unit tests, generate coverage reports, and run benchmarks.

2|Updated Aug 6, 2021
One-click install
npx skills add https://github.com/MrPointer/dotfiles --skill testing-go-code
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-go-code
Source: https://github.com/MrPointer/dotfiles/tree/main/.claude/skills/testing-go-code
Command: npx skills add https://github.com/MrPointer/dotfiles --skill testing-go-code

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires mockery, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill streamlines the process of verifying the quality and performance of Go code by automating testing, coverage analysis, and benchmarking.

Core Features & Use Cases

  • Unit Tests: Execute all Go unit tests, including race detection and selective test runs.
  • Coverage Reports: Generate HTML reports detailing code coverage.
  • Benchmarking: Run performance benchmarks and analyze memory allocations.
  • Mock Generation: Automatically regenerate mock implementations for interfaces.
  • Use Case: After modifying an interface in your Go project, use this Skill to regenerate the necessary mock files and then run all tests to ensure the changes haven't introduced regressions.

Quick Start

Run all Go unit tests with race detection enabled.

Frequently Asked Questions about testing-go-code

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

FAQPage Schema
How do I run Go unit tests with race detection and generate a code coverage report?

Run Go unit tests with race detection and generate HTML coverage reports by executing commands from the Go module root, streamlining verification of code quality and identifying data races.

What's the best way to regenerate mock implementations for Go interfaces after modifications?

Regenerate mock implementations for modified Go interfaces using mockery dependencies, then execute unit tests to ensure interface changes have not introduced regressions across the module.

Can I run performance benchmarks and analyze memory allocations for a Go module?

Run performance benchmarks to analyze Go code behavior and measure memory allocations directly, providing insights into execution speed and resource consumption for optimized performance.

Do I need a Go module root context to execute tests and benchmarks?

Yes, executing Go unit tests, generating coverage reports, and running benchmarks requires a Go module root context to correctly resolve dependencies and execute commands.

How does generating HTML code coverage reports help verify Go code quality?

Generating HTML code coverage reports details which Go code paths are executed during unit tests, visually highlighting untested branches to guide quality improvements and prevent regressions.