Documentation
¶
Overview ¶
Package testify provides comprehensive assertion packages for Go testing.
Overview ¶
This is the go-openapi fork of testify, designed with zero external dependencies and a focus on maintainability. The codebase uses code generation more extensively than the original testify. This helps maintain consistency across all assertion variants.
Packages ¶
The assert package provides a comprehensive set of assertion functions that integrate with Go's testing framework. Assertions return boolean values allowing tests to continue after failures.
The require package provides the same assertions but with fatal checks that stop test execution immediately on failure via testing.T.FailNow.
Key Differences from stretchr/testify ¶
This fork prioritizes:
- Zero external dependencies (go-spew and difflib are internalized)
- Removed mock and suite packages (favor the use mockery or similar specialized tools instead)
- Optional features via enable packages (e.g., enable/yaml for YAML assertions)
- Code generation ensures consistency across 76 assertion functions × 8 variants
Optional Features ¶
YAML assertions require importing the enable package:
import _ "github.com/go-openapi/testify/v2/enable/yaml"
Without this import, YAMLEq and YAMLEqf will panic loudly with a helpful error message.
Note on testifylint ¶
The golangci-lint compatible linter testifylint is designed for stretchr/testify and will not work with this fork as it checks only for the original dependency.
Directories
¶
| Path | Synopsis |
|---|---|
|
enable/colors
Package colors is an indirection to handle colorized output.
|
Package colors is an indirection to handle colorized output. |
|
enable/yaml
Package yaml is an indirection to handle YAML deserialization.
|
Package yaml is an indirection to handle YAML deserialization. |
|
Package enable contains go modules with extra-dependencies.
|
Package enable contains go modules with extra-dependencies. |
|
internal
|
|
|
assertions
Package assertions holds the internal implementation of all the helper functions exposed by testify.
|
Package assertions holds the internal implementation of all the helper functions exposed by testify. |
|
assertions/enable
Package enable allows to register extra features.
|
Package enable allows to register extra features. |
|
assertions/enable/yaml
Package yaml is an indirection to handle YAML deserialization.
|
Package yaml is an indirection to handle YAML deserialization. |
|
assertions/unsafetests
Package unsafetests exists only to isolate tests that reference the unsafe package.
|
Package unsafetests exists only to isolate tests that reference the unsafe package. |
|
difflib
Package difflib is a partial port of Python difflib module.
|
Package difflib is a partial port of Python difflib module. |
|
spew
Package spew implements a deep pretty printer for Go data structures to aid in debugging.
|
Package spew implements a deep pretty printer for Go data structures to aid in debugging. |
|
spew/testsrc
Package testsrc is a package for testing spew with cgo.
|
Package testsrc is a package for testing spew with cgo. |
|
Package require implements the same assertions as the assert package but stops test execution when a test fails.
|
Package require implements the same assertions as the assert package but stops test execution when a test fails. |