testify

The essential Go toolkit for assertions, mocks, and structured test suites.

Library
Go
vv1.12.1
26,217 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
75 /100 Good
Development Activity 76
Maintenance 56
Community 68
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
84 /100 Excellent
Architecture 85
Code Quality 88
Innovation 80
Learning Curve 88

Testify is the most widely used testing toolkit for Go, providing a comprehensive set of assertion helpers, a mocking framework, and a structured test-suite system that plays nicely with the standard testing package. Rather than replacing Go’s built-in test runner, it layers ergonomic, readable APIs on top of it, cutting boilerplate from equality checks, error handling, and object mocking in day-to-day test code.

With hundreds of contributors and more than a decade of production use across the Go ecosystem, testify has become a near-default dependency in Go projects of every size, from small CLIs to large distributed systems, valued for its stability, minimal external surface, and tight integration with go test.

What You Get

  • assert package with 100+ assertion functions (Equal, Nil, Error, Contains, Len, and more) that print human-readable failure diffs
  • require package mirroring assert but calling t.FailNow() to halt the test immediately on failure
  • mock package for building mock objects with expectation-based call verification (On/Return/AssertExpectations)
  • suite package for grouping tests as struct methods with SetupTest/TearDownTest lifecycle hooks
  • A testifylint linter (via golangci-lint) that catches common assertion misuse

Common Use Cases

  • Asserting expected vs actual values in unit tests without hand-writing comparison and error-formatting code
  • Mocking external dependencies (HTTP clients, databases, third-party APIs) to isolate the unit under test
  • Structuring integration-style tests as a suite with shared setup/teardown across many related test methods
  • Enforcing fail-fast behavior on prerequisite checks via require so a broken precondition doesn’t cascade into confusing downstream failures

Under The Hood

Architecture Testify is organized as four largely independent packages that share a common internal core: assert (raw boolean-returning assertion functions plus a generated require-style companion), require (a codegen-generated mirror of assert that calls t.FailNow() on failure, built from require.go.tmpl via go:generate), mock (a Mock/Call/Arguments object model layered on testify/assert for value comparison and stretchr/objx for structured argument objects), and suite (a Suite struct plus lifecycle hooks like SetupTest/TearDownTest that suite.Run drives via reflection over Test* methods). Shared formatting and diffing logic lives in internal/difflib (a Python difflib port) and internal/spew (a vendored pretty-printer), so all four public packages produce consistent, readable failure output. Code generation (assertion_format.go.tmpl, require.go.tmpl, driven by the _codegen tool) keeps require and the formatted-assertion variants mechanically in sync with the hand-written comparison logic in assertion_compare.go and assertions.go.

Tech Stack The module targets Go 1.17+ with a minimal dependency footprint: github.com/stretchr/objx v0.5.3 (structured mock argument access) and gopkg.in/yaml.v3 v3.0.1 (YAML equality assertions). There is no build system beyond the standard go build/go generate toolchain — _codegen is a small internal Go program invoked via go:generate directives, and CI runs go test across supported Go versions. No external services, databases, or runtime dependencies are involved; it is a pure compile-time test-support library.

Code Quality Testify is thoroughly self-tested: 21 _test.go files across the repo, including assertions_test.go, mock_test.go, and suite_test.go, exercise the library’s own assertion, mocking, and suite-lifecycle behavior. Core files like assert/assertions.go (2,314 lines) and mock/mock.go (1,311 lines) are large but organized into clearly delimited, doc-commented functions, and generated files are explicitly marked with “Code generated with” headers per CONTRIBUTING.md, so hand-written and generated code stay unambiguous. Error handling favors explicit boolean returns and TestingT.Errorf/FailNow() calls over panics, consistent with idiomatic Go testing conventions; the project also ships MAINTAINERS.md and EMERITUS.md, signaling active ownership.

API Design Testify’s defining design choice is layering two near-identical APIs — assert (returns bool, continues the test) and require (calls t.FailNow(), halts the test) — over the same underlying comparisons, letting callers choose failure semantics per call site. Every function accepts a TestingT interface rather than a concrete *testing.T, keeping the library decoupled from the standard library. Getting started requires zero configuration: assert.Equal(t, want, got) works with a single import, and the mock.Mock embed-and-call pattern is idiomatic enough to be treated as a de facto standard by adjacent tools like mockery and testifylint. The main friction point is the size of the API surface (100+ assertion functions) and the deliberate v1 feature-freeze, which keeps the DX stable but leaves some rough edges (e.g. suite not supporting parallel tests) unresolved by design.

Used by 102 apps in this directory

Python
55%
Other

PostHog

Ab Testing Experimentation · Analytics · Developer Tools

39,975

The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.

View details
92
Repo Health
80
Technical
65
Dependency
Built with
Python 55%
TypeScript 36%
Updated 1 weeks ago
TypeScript
56%
AGPL 3.0

Prisme Analytics

Analytics

135

A self-hosted, privacy-focused web analytics platform built on Go and ClickHouse, with a ~2KB cookieless tracking script and Grafana-based dashboards for users, teams, and multi-organization access.

View details
39
Repo Health
61
Technical
76
Dependency
Built with
TypeScript 56%
Go 38%
Updated 7 months ago
Go
90%
AGPL 3.0

Pyroscope

Developer Tools · Devops · Monitoring

11,678

An open-source, horizontally scalable continuous profiling platform that pinpoints CPU, memory, and I/O bottlenecks down to the exact line of code, built by Grafana Labs alongside Loki, Tempo, and Mimir.

View details
91
Repo Health
89
Technical
65
Dependency
Built with
Go 90%
Updated 2 weeks ago
Go
39%
Apache 2.0

Rill

Analytics · Data Engineering

2,914

The fastest BI tool for humans and agents — define metrics, models, and dashboards as code and query them instantly on ClickHouse or DuckDB.

View details
87
Repo Health
88
Technical
64
Dependency
Built with
Go 39%
TypeScript 38%
Svelte 21%
Updated 2 weeks ago
Rust
72%
Apache 2.0

Rivet

AI Agents · Developer Tools

6,195

Stateful actors as a primitive for AI agents, real-time collaboration, and durable execution — with in-memory state, WebSockets, queues, and scheduling built in.

View details
86
Repo Health
81
Technical
64
Dependency
Built with
Rust 72%
TypeScript 25%
Updated 1 weeks ago
Go
54%
MPL 2.0

shaper

Analytics · Data Engineering

1,251

Build analytics dashboards, reports, and customer-facing analytics by writing pure SQL — powered by DuckDB and designed for self-hosted deployment.

View details
80
Repo Health
79
Technical
74
Dependency
Built with
Go 54%
TypeScript 45%
Updated 1 weeks ago
TypeScript
50%
Other

SigNoz

Analytics · Monitoring

32,224

Self-host your entire observability stack — logs, metrics, traces, and LLM monitoring — in one OpenTelemetry-native platform, without the Datadog bill.

View details
92
Repo Health
83
Technical
67
Dependency
Built with
TypeScript 50%
Go 38%
Updated 1 weeks ago
Go
98%
Apache 2.0

Space Cloud

Authentication · Devops

4,002

Kubernetes-native serverless platform that generates instant GraphQL and REST APIs for any database with built-in auth and real-time subscriptions

View details
50
Repo Health
74
Technical
63
Dependency
Built with
Go 98%
Updated 2 years ago
Go
100%
Apache 2.0

SpiceDB

Authentication · Databases · Security

7,101

An open source, Google Zanzibar-inspired authorization database that models permissions as relationships and evaluates fine-grained access checks at massive scale with single-digit millisecond latency.

View details
89
Repo Health
89
Technical
67
Dependency
Built with
Go 100%
Updated 2 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers