test-with-gt

Generate Go unit tests with type-safe gt library assertions.

10|2|Updated Dec 4, 2022
One-click install
npx skills add https://github.com/m-mizutani/gt --skill test-with-gt
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-with-gt
Source: https://github.com/m-mizutani/gt/tree/main/docs/skills
Command: npx skills add https://github.com/m-mizutani/gt --skill test-with-gt

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill simplifies writing robust and type-safe tests for Go code, reducing common testing errors and improving code quality.

Core Features & Use Cases

  • Type-Safe Assertions: Ensures compile-time type checking for test assertions.
  • Method Chaining: Allows for fluent and readable test sequences.
  • Fail-Fast Option: Enables immediate test termination on critical failures.
  • Descriptive Errors: Provides context-rich error messages for easier debugging.
  • Use Case: When you need to assert that a slice of user objects has a specific length and contains a particular user, or when validating error returns from functions.

Quick Start

Use the test-with-gt skill to write a Go test for the provided code snippet using gt.Value assertions.

Frequently Asked Questions about test-with-gt

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

FAQPage Schema
How do I write type-safe unit tests in Go using the gt library?

Type-safe unit tests in Go use the gt library to generate assertions with compile-time checking. This ensures invalid comparisons fail during compilation rather than at runtime, reducing common testing errors.

What is method chaining in Go test assertions and how does gt support it?

Method chaining in Go test assertions allows fluent and readable test sequences. The gt library supports this feature, enabling developers to link multiple type-safe assertions together for clearer validation logic.

Can I stop Go test execution immediately when a critical assertion fails?

Yes, you can stop Go test execution immediately using the fail-fast option. This feature enables immediate test termination on critical failures, preventing subsequent assertions from running after a fatal error.

Does the gt library support assertions for Go maps, slices, strings, and errors?

Yes, the gt library supports assertions for Go maps, slices, strings, numbers, booleans, and errors. It generates code to validate value comparisons, array lengths, and error returns with descriptive context-rich error messages.

Why should I use type-safe assertions instead of standard Go testing for unit tests?

Type-safe assertions catch type mismatches at compile time rather than runtime, improving code quality. Standard Go testing lacks built-in fluent method chaining and fail-fast execution options available in the gt library.