gotests
gotests is a Go code generator that automatically creates table-driven test boilerplate from function signatures. It supports Go 1.22+, includes optional AI-powered test case generation via Ollama, and integrates with popular editors (VS Code, IntelliJ, Vim, Sublime).
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | cweill/gotests |
| Owner | cweill |
| Primary language | Go |
| License | Apache-2.0 — OSI-approved |
| Stars | 5.3k |
| Forks | 351 |
| Open issues | 39 |
| Latest release | v1.9.0 (2025-10-28) |
| Last updated | 2025-10-30 |
| Source | https://github.com/cweill/gotests |
What gotests is
CLI tool written in Go that parses function/method signatures and generates test scaffolding with configurable templates, subtest support, and optional LLM-based test case generation. Supports generics (Go 1.18+), custom templates, and recursive directory processing.
Get the gotests source
Clone the repository and explore it locally.
git clone https://github.com/cweill/gotests.gitcd gotests# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Install via `go install` (Go 1.22+); tool integrates as CLI or editor plugin. No runtime dependencies beyond Go standard library for core functionality.
- AI features require local Ollama installation and a compatible model (e.g., qwen2.5-coder:0.5b, llama3.2); ensure adequate disk/memory for model storage.
- Generated test files must still be reviewed for correctness; generated assertions and edge cases are scaffolding, not validated logic.
- Custom templates can be provided via -template_dir or environment variable GOTESTS_TEMPLATE_DIR; default templates support table-driven tests and testify.
- Use -excl, -only, -exported, -all flags to control function selection; -w writes output to files, stdout otherwise.
When to avoid it — and what to weigh
- Your team requires generated tests to be production-ready immediately — gotests generates scaffolding and boilerplate; test logic and assertions still require manual review and refinement. AI generation may produce incorrect assertions or miss business logic intent.
- You need generated tests to include business logic validation — The tool generates structural test templates but cannot infer complex validation logic or integration test scenarios. Manual assertion implementation is always required.
- Your functions contain sensitive data, secrets, or proprietary algorithms — AI mode sends complete function bodies to the LLM (local Ollama by default, but future cloud integrations possible). Avoid -ai flag on security-sensitive code.
- You require Go versions earlier than 1.22 — Minimum supported version is Go 1.22; no backwards compatibility for older Go releases.
License & commercial use
Licensed under Apache License 2.0 (Apache-2.0), an OSI-approved permissive license. Permits commercial use, modification, and distribution with minimal restrictions (attribution, license notice required).
Apache-2.0 is a permissive OSI license that explicitly permits commercial use. You may use, modify, and distribute gotests in commercial products provided you retain license notices and copyright attribution. No license fees or restrictions on derived works. Typical legal review recommended for company-internal use policies.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Strong |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Good |
| Assessment confidence | High |
No inherent security vulnerabilities disclosed, but tool-specific considerations: (1) AI mode transmits function source code to Ollama (local by default); avoid on code containing secrets, keys, or proprietary algorithms. (2) Generated test files inherit the security posture of source code. (3) Editor plugins may have separate security policies. (4) Tool does not introduce cryptographic or network features in standard mode; AI mode depends on Ollama security.
Alternatives to consider
testify/suite
Manual test framework offering more structured assertions and setup/teardown hooks; requires explicit test writing but provides fine-grained control and assertion clarity.
Table-driven test patterns (manual)
Write table-driven tests by hand to maintain full control over test logic and edge cases; no generation overhead but higher initial effort and less consistency.
GoMock / mockgen
Focuses on mocking and interface test generation rather than boilerplate scaffolding; complementary to gotests for testing with dependencies and external services.
Build on gotests with DEV.co software developers
Evaluate gotests for rapid test scaffolding and optional AI-assisted test case generation. Start with `go install github.com/cweill/gotests/gotests@latest` and review generated tests before committing.
Talk to DEV.coRelated on DEV.co
Explore the category and the services that help you build with it.
gotests FAQ
Does gotests write actual test logic or just scaffolding?
Can I use AI test generation offline?
Is the generated code thread-safe or production-ready?
What Go versions are supported?
Software developers & web developers for hire
DEV.co is a software development agency delivering custom software development services to companies building on open source. Our software developers and web developers design, integrate, and ship production systems — spanning web development, APIs, AI, data, and cloud. If gotests is part of your open-source testing roadmap, our team can implement, customize, migrate, and maintain it.
Ready to streamline your Go testing workflow?
Evaluate gotests for rapid test scaffolding and optional AI-assisted test case generation. Start with `go install github.com/cweill/gotests/gotests@latest` and review generated tests before committing.