Download Latest Version v1.9.0 - AI-Powered Test Generation source code.tar.gz (89.3 kB)
Email in envelope

Get an email when there's a new version of gotests

Home / v1.8.0
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2025-10-21 2.2 kB
v1.8.0 - Full Go Generics Support source code.tar.gz 2025-10-21 51.0 kB
v1.8.0 - Full Go Generics Support source code.zip 2025-10-21 144.0 kB
Totals: 3 Items   197.2 kB 0

🎉 Full Go Generics Support

This release adds complete support for Go generics (type parameters), enabling gotests to generate tests for generic functions and methods on generic types.

✨ Key Features

  • 🔧 Generic Functions: Generate tests for functions with type parameters go func FindFirst[T comparable](slice []T, target T) (int, error)

  • 🏗️ Generic Types: Support for methods on generic types go type Set[T comparable] struct { ... } func (s *Set[T]) Add(v T)

  • 🎯 All Constraint Types: any, comparable, union types (int64 | float64), approximation (~int)

  • 🧠 Smart Type Mapping: Intelligent defaults for type instantiation

  • anyint
  • comparablestring
  • Union types → first option
  • Approximation → underlying type

  • 🔄 Multiple Type Parameters: Handles functions like Pair[T, U any]

📊 Test Coverage

  • 97.5% main package coverage
  • 83.5% overall project coverage
  • 100% coverage on all new parser functions
  • ✅ 8 comprehensive generic test patterns

🔧 Technical Improvements

Parser Enhancements: - New parseTypeDecls() extracts type parameters from type declarations - New parseTypeParams() parses AST field lists - New extractBaseTypeName() handles receiver types

Template Functions: - TypeArgs - generates concrete type arguments for calls - FieldType - substitutes type parameters in field declarations - ReceiverType - substitutes type parameters in receiver instantiations

Model Updates: - New TypeParam struct - Added TypeParams field to Function - Helper methods: IsGeneric(), HasGenericReceiver()

📚 Documentation

Added comprehensive "Go Generics Support" section to README with: - Example: Generic function test generation - Example: Methods on generic types - Type constraint mapping reference

🐛 Fixes

Closes [#165]

📦 Installation

:::bash
go install github.com/cweill/gotests/gotests@v1.8.0

🙏 Credits

🤖 Developed with assistance from Claude Code


Full Changelog: https://github.com/cweill/gotests/compare/v1.7.0...v1.8.0

Source: README.md, updated 2025-10-21