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.9.0
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2025-10-27 4.5 kB
v1.9.0 - AI-Powered Test Generation source code.tar.gz 2025-10-27 89.3 kB
v1.9.0 - AI-Powered Test Generation source code.zip 2025-10-27 199.5 kB
Totals: 3 Items   293.3 kB 0

πŸ€– AI-Powered Test Generation

This release adds AI-powered test case generation using local LLMs via Ollama, enabling automatic generation of intelligent, realistic test cases.

✨ Key Features

  • 🧠 Intelligent Test Cases: AI analyzes function implementation to generate realistic test values, edge cases, and error conditions
  • 🏠 Local-First & Private: Uses Ollama to run LLMs locally - your code never leaves your machine
  • ⚑ Fast Small Models: Default qwen2.5-coder:0.5b model (400MB) generates tests in seconds
  • 🎯 Smart Coverage: Automatically identifies edge cases, error conditions, and validation logic
  • πŸ”§ Flexible: Support for simple types, complex types, methods, variadic params, and multiple return values
  • πŸ“Š Configurable: Adjust min/max test cases, choose different models, or use custom endpoints

πŸš€ Quick Start

:::bash
# Install Ollama (one-time setup)
curl -fsSL https://ollama.com/install.sh | sh
ollama serve &
ollama pull qwen2.5-coder:0.5b

# Generate tests with AI
gotests -all -ai -w yourfile.go

πŸ“ Example

Given this function:

:::go
func CalculateDiscount(price float64, percentage int) (float64, error) {
    if price < 0 {
        return 0, errors.New("price cannot be negative")
    }
    if percentage < 0 || percentage > 100 {
        return 0, errors.New("percentage must be between 0 and 100")
    }
    return price - (price * float64(percentage) / 100.0), nil
}

AI generates: - βœ… Valid input test case - βœ… Negative price error case - βœ… Invalid percentage error case - βœ… Proper error handling and assertions

πŸŽ›οΈ Configuration Options

:::bash
# Use different model
gotests -all -ai -ai-model llama3.2:latest -w file.go

# Generate specific number of test cases (min = max)
gotests -all -ai -ai-min-cases 5 -ai-max-cases 5 -w file.go

# Generate range of test cases (AI chooses 3-7)
gotests -all -ai -ai-min-cases 3 -ai-max-cases 7 -w file.go

# Custom Ollama endpoint
gotests -all -ai -ai-endpoint http://custom:11434 -w file.go

πŸ”’ Privacy & Security

  • βœ… Local-first by default - Using Ollama keeps all data on your machine
  • βœ… Offline operation - Works completely offline with local models
  • ⚠️ Function bodies are analyzed - Business logic and code comments are sent to the LLM
  • πŸ”’ Recommendation: Avoid using -ai on code containing secrets or API keys

πŸ“Š Test Coverage Improvements

  • Increased overall project coverage from 28.1% to 84.6% (#196)
  • Added comprehensive tests for:
  • internal/goparser package
  • internal/models package
  • internal/output package
  • internal/render package
  • gotests/process package

πŸ“š Documentation Enhancements

  • Added godoc comments to all exported functions (#195)
  • Expanded README with:
  • AI-powered test generation section
  • Quick start examples
  • Privacy and security considerations
  • Configuration options and examples

πŸ› οΈ Technical Implementation

New Packages: - internal/ai - AI provider abstraction layer - Ollama provider with health checks and retries - Go-specific prompt engineering - Response parsing and validation - E2E test suite with golden file validation

CLI Flags: - -ai - Enable AI test case generation - -ai-model - Select model (default: qwen2.5-coder:0.5b) - -ai-endpoint - Ollama endpoint (default: http://localhost:11434) - -ai-min-cases - Minimum test cases to generate (default: 3) - -ai-max-cases - Maximum test cases to generate (default: 10)

Architecture: - Provider-based design for future LLM support - Language-agnostic core with Go-specific implementation - Graceful fallback to TODO comments on generation failure - Integration with existing template rendering pipeline

πŸ› Known Issues

  • Issue [#197]: 4 out of 11 E2E tests disabled due to environment-dependent LLM non-determinism
  • Does not affect functionality, only E2E test validation
  • 7 E2E tests pass consistently on first attempt
  • Will be addressed in future patch release

πŸ“¦ Installation

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

πŸ™ Credits

πŸ€– Developed with assistance from Claude Code


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

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