DEV.co
Open-Source Testing · cweill

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).

Source: GitHub — github.com/cweill/gotests
5.3k
GitHub stars
351
Forks
Go
Primary language
Apache-2.0
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositorycweill/gotests
Ownercweill
Primary languageGo
LicenseApache-2.0 — OSI-approved
Stars5.3k
Forks351
Open issues39
Latest releasev1.9.0 (2025-10-28)
Last updated2025-10-30
Sourcehttps://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.

Quickstart

Get the gotests source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/cweill/gotests.gitcd gotests# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Rapid test scaffolding for new Go projects

Generate consistent, boilerplate-free table-driven test structure across a codebase, reducing manual setup time and enforcing uniform test patterns.

Legacy Go codebase test coverage expansion

Quickly generate test skeletons for functions lacking test coverage, enabling teams to systematize testing without rewriting function logic.

AI-assisted test case generation with local models

Use Ollama integration to auto-generate realistic edge cases and error scenarios offline, reducing manual test case design for straightforward functions.

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.

SignalAssessment
MaintenanceActive
DocumentationStrong
License clarityClear
Deployment complexityLow
DEV.co fitGood
Assessment confidenceHigh
Security considerations

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.

Software development agency

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.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related 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?
gotests generates test structure (function signatures, table layouts, boilerplate imports). Test assertions and edge cases are provided as placeholders or via AI (which still requires review); you must implement actual validation logic.
Can I use AI test generation offline?
Yes. AI mode uses Ollama by default, which runs locally. Install Ollama, pull a model (e.g., qwen2.5-coder:0.5b), and run gotests -ai -w. No cloud calls unless configured otherwise.
Is the generated code thread-safe or production-ready?
Generated test code uses standard Go testing patterns (t.Run subtests for concurrency). However, it is scaffolding; you must review assertions, add mocks, and validate logic before production use.
What Go versions are supported?
Minimum Go 1.22. Full generics support (Go 1.18+). No backwards compatibility for earlier versions.

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.