| Name | Modified | Size | Downloads / 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
-aion 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