For a testing assertions and mocking library for Go, the first results are stretchr/testify (stretchr/testify is the de facto standard Go testing library, offering both assertion functions and a mocking framework that integrate seamlessly with go test, which directly matches the need for a simple yet powerful testing toolkit), golang/mock (GoMock is a powerful mocking framework for Go, but it lacks assertion functions, so it only partially meets the need for a combined assertion and mocking library; you would need to pair it with a separate assertion package) and cweill/gotests (gotests generates test scaffolding and boilerplate from source code, but it does not provide assertion functions or mocking capabilities; it's a test generation tool rather than a library for writing tests with assertions and mocks). smartystreets/goconvey and onsi/ginkgo round out the shortlist. Compare the match explanations and check the project documentation against your requirements.
Collection of libraries for writing unit tests, managing test assertions, and creating mock objects in Go.
Testify is a comprehensive testing toolkit for Go that provides a suite of assertion libraries and mocking frameworks to validate code behavior. It enables developers to write automated tests by comparing actual results against expected outcomes, ensuring that functional requirements are met throughout the development process. The project distinguishes itself through its flexible failure propagation, which allows tests to either halt execution immediately upon a failed requirement or return boolean results for conditional logic. It includes deep-equality object comparison and JSON normalizati
stretchr/testify is the de facto standard Go testing library, offering both assertion functions and a mocking framework that integrate seamlessly with go test, which directly matches the need for a simple yet powerful testing toolkit.
GoMock is a mocking framework for the Go programming language.
GoMock is a powerful mocking framework for Go, but it lacks assertion functions, so it only partially meets the need for a combined assertion and mocking library; you would need to pair it with a separate assertion package.
gotests is a static analysis tool and boilerplate generator for Go that automatically creates structured test suites from source code. It functions as a table-driven test framework that handles type resolution for functions and methods, including the mapping of generic type constraints to concrete implementation types. The tool integrates with large language models to synthesize realistic input values and edge cases based on function logic. It uses a template-driven generation system, allowing the structure and format of the resulting test code to be customized through external templates and
gotests generates test scaffolding and boilerplate from source code, but it does not provide assertion functions or mocking capabilities; it's a test generation tool rather than a library for writing tests with assertions and mocks.
GoConvey is a behavioral testing framework for the Go programming language that provides a test runner, a code coverage tool, and a web-based monitoring dashboard. It integrates with the standard Go test command to organize tests into behavioral stories and conveyors. The project features a web interface that monitors the file system for source code changes and automatically triggers test execution to provide real-time feedback. This dashboard displays test results, failures, and a chronological history of execution status. The framework includes a state assertion system for verifying values
GoConvey is a behavioral test framework with a web dashboard and state assertions, but it lacks mocking capabilities and is not a focused assertion-and-mocking library for simplifying test writing.
Ginkgo is a behavior-driven development testing framework, assertion library, and test runner for Go. It provides a domain-specific language for writing human-readable specifications, organizing tests into hierarchical containers and subjects to describe system behavior. The project distinguishes itself through advanced execution control and observability, featuring a test runner capable of parallel distribution, sharding, and randomized execution order to detect flaky tests. It includes specialized diagnostic tools for goroutine leak detection, hanging spec monitoring, and failure state debu
Ginkgo is a full BDD testing framework with assertion capabilities and some mock support (HTTP mock servers), but it is more comprehensive than the focused assertion-and-mocking library you're looking for, and its DSL is not minimal.
Terratest is a Go library and testing framework designed for automating the deployment, validation, and destruction of infrastructure stacks. It serves as a cloud resource verification tool that interacts with provider APIs and executes remote shell commands to ensure infrastructure definitions are correctly configured. The framework provides specialized support for validating Terraform modules and Kubernetes deployments, including the verification of container orchestration manifests and Helm charts. It distinguishes itself through the use of Docker container utilities for script execution a
Terratest is a Go library for testing infrastructure (Terraform, Kubernetes, Docker) rather than a general-purpose assertion and mocking library for Go code, so it does not directly match your search for simplifying standard Go unit tests.
Keploy is an automated testing platform that leverages kernel-level traffic interception to generate and maintain regression test suites for microservices. By capturing live network traffic and system calls via eBPF, the platform automatically creates deterministic test cases and mocks external dependencies without requiring manual code instrumentation. This approach allows developers to validate application behavior and API contracts by replaying production-like traffic in isolated environments. The platform distinguishes itself through its use of machine learning to perform test maintenance
Keploy is an automated testing platform that generates test cases from network traffic, not a Go library you import for assertion functions and mocking in your own tests — it automates testing rather than providing test-writing primitives.
| Repository | Stars | Language | License | Last push |
|---|---|---|---|---|
| stretchr/testify | 25.9K | Go | mit | |
| golang/mock | 9.4K | Go | Apache-2.0 | |
| cweill/gotests |
| 5.3K |
| Go |
| Apache-2.0 |
| smartystreets/goconvey | 8.4K | Go | NOASSERTION |
| onsi/ginkgo | 9K | Go | MIT |
| gruntwork-io/terratest | 7.9K | Go | apache-2.0 |
| keploy/keploy | 17.6K | Go | Apache-2.0 |