Compétences golang-testing
đź§Ş

golang-testing

Sûr

Write Effective Go Tests

Également disponible depuis: Joseph OBrien

Writing tests in Go can be challenging without guidance on patterns and best practices. This skill provides comprehensive examples for table-driven tests, mocking, integration testing with containers, and performance benchmarks.

Prend en charge: Claude Codex Code(CC)
📊 69 Adéquat
1

Télécharger le ZIP du skill

2

Importer dans Claude

Allez dans Paramètres → Capacités → Skills → Importer un skill

3

Activez et commencez Ă  utiliser

Tester

Utilisation de "golang-testing". How do I write tests for a function that adds two numbers?

Résultat attendu:

  • Use table-driven tests with t.Run for each case:
  • Test positive numbers, negative numbers, mixed signs, and zeros
  • Use t.Errorf to report failures with expected vs actual values
  • Group related tests in a slice of test cases for maintainability

Audit de sécurité

Sûr
v3 • 1/10/2026

This is a pure prompt-based skill containing only markdown documentation about Go testing patterns. No executable code, scripts, network calls, or file system access. The skill provides informational guidance only.

1
Fichiers analysés
428
Lignes analysées
0
résultats
3
Total des audits
Aucun problème de sécurité trouvé

Score de qualité

38
Architecture
100
Maintenabilité
81
Contenu
33
Communauté
100
Sécurité
78
Conformité aux spécifications

Ce que vous pouvez construire

Learn Test Patterns

Master table-driven tests, mocking, and test organization for production Go code.

Integration Testing

Set up integration tests with test containers for databases and external services.

Benchmark Code

Write and run benchmarks to measure and optimize performance-critical code sections.

Essayez ces prompts

Basic Table Test
Show me how to write a table-driven test in Go for a function called Divide that takes two integers and returns the quotient and an error.
Mock Dependencies
How do I create a mock for a UserRepository interface to test my UserService without a real database?
Integration Tests
Write an integration test using testcontainers to test my repository against a real PostgreSQL database.
Performance Benchmarks
Show me how to write a Go benchmark for a sorting function with different input sizes.

Bonnes pratiques

  • Test behavior, not implementation - focus on inputs and outputs rather than internal details
  • Use t.Helper() to mark helper functions for clearer error reporting
  • Run independent tests in parallel with t.Parallel() to speed up test suites

Éviter

  • Avoid one test with many assertions - split into focused test cases
  • Do not skip t.Cleanup() for resource management
  • Avoid hardcoding test data - use test fixtures or factories instead

Foire aux questions

What Go versions are supported?
Works with Go 1.14 and later versions. Examples use standard library testing package.
What is the maximum test complexity supported?
No limits. Patterns scale from simple unit tests to complex integration test suites.
How do I integrate with existing test frameworks?
Compatible with testify, ginkgo, gocheck, and other testing libraries. Examples use standard patterns.
Does this skill modify my project files?
No. This skill provides guidance and examples only. It does not read or write any project files.
Why are my tests failing?
Check that your test file ends with _test.go and is in the same package as your code. Verify test function signatures use *testing.T parameter.
How is this different from Go's built-in testing?
This skill enhances Go's built-in testing with patterns, best practices, and examples. It builds on standard testing features.

Détails du développeur

Structure de fichiers

đź“„ SKILL.md