README
The v2 our tests wanted
Why choose go-openapi/testify/v2
- 95% compatible with
stretchr/testify— if you already use it, our migration tool automates the switch - Actively maintained: regular fixes and evolutions, many PRs proposed upstream are already in
- Zero external dependencies — you import what you need, with opt-in modules for extras (e.g. YAML, colorized output)
- Modernized codebase targeting go1.24+
- Go routine leak detection built in: zero-setup, no false positives, works with parallel tests (unlike
go.uber.org/goleak) - File descriptor leak detection (linux-only)
- Type-safe assertions with generics (see a basic example) — migration to generics can be automated too. Read the full story
- Safe async assertions, extended JSON & YAML assertions
- Coming in
v2.5.0: non-flaky async assertions usingsynctest, and internal tools exposed as standalone modules (spew, unified diff, goleak) - We take documentation seriously: searchable doc site with testable examples and a complete tutorial, plus detailed godoc for every assertion
This fork isn’t for everyone
- You need the
mockpackage — we removed it and won’t bring it back. For suites, we’re open to discussion about a redesigned approach - Your project must support Go versions older than 1.24
- You rely on
testifylintor other tooling that expects thestretchr/testifyimport path - You need 100% API compatibility — we’re at 95%, and the remaining 5% are intentional removals
Motivation
See why we wanted a v2.
Approach with this fork
This fork targets go1.24.
- zero external dependencies by default
- extra features (and dependencies) are opt-in
- modernized code base
- simplified maintenance
- can add or remove assertions with ease
- mitigated API bloat with comprehensive domain-indexed documentation
- can leverage generics without backward compatibility concerns
The approach will be selective and pragmatic rather than comprehensive:
- Targeted improvements where generics provide clear value without compromising existing functionality
- Focus on eliminating anti-patterns like dummy value instantiation in
IsType(see #1805) - Preserve reflection-based flexibility for comparing complex types rather than forcing everything through generic constraints
- Careful constraint design to ensure type safety without being overly restrictive or permissive
The goal is to enhance type safety and developer experience where it matters most, while maintaining the flexibility that makes testify useful for real-world testing scenarios.
Breaking changes from v1
YAMLEqpanics by default: must enable the feature with an additional blank import- deprecated types and methods have been removed
- removed the
suite,mocksandhttppackages - replaced internal utility package
_codegenbycodegen
See all changes from v1 and check out our ROADMAP.
API Stability Guarantee
The assertions currently used by go-openapi projects constitute our stable API. These entry points will remain backward compatible. Other assertions may evolve as we refine the v2 API.
See Also
Getting Started:
- Examples - Practical code examples for using testify v2
- Usage Guide - API conventions and navigation guide
- Migration Guide - Migrating from stretchr/testify v1
Project Documentation:
- Changes from v1 - Complete list of changes and new features
- Roadmap - Future development plans
- Architecture - Technical architecture and design decisions
- Contributing - How to contribute to this project
- The original README