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: 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 many assertion functions × 4 to 8 variants
Optional Features ¶
YAML assertions require importing the enable package:
import _ "github.com/go-openapi/testify/v2/enable/yaml"
Without this import, assert.YAMLEq and require.YAMLEq will panic loudly with a helpful error message.
Note on testifylint ¶
testifylint is a linter compatible with golangci-lint. It is designed for stretchr/testify and will not work with this fork as it checks only for the original dependency.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package assert provides a set of testing tools for use with the standard Go testing system.
|
Package assert provides a set of testing tools for use with the standard Go testing system. |
|
Package enable contains go modules with extra-dependencies.
|
Package enable contains go modules with extra-dependencies. |
|
stubs
Package stubs provides public APIs for enabling optional features in testify.
|
Package stubs provides public APIs for enabling optional features in testify. |
|
stubs/colors
Package colors is an indirection to handle colorized output.
|
Package colors is an indirection to handle colorized output. |
|
stubs/yaml
Package yaml is an indirection to the internal implementation that handles YAML deserialization.
|
Package yaml is an indirection to the internal implementation that handles YAML deserialization. |
|
internal
|
|
|
assertions
Package assertions holds the internal implementation of all the assertion and helper functions exposed by testify.
|
Package assertions holds the internal implementation of all the assertion and 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 serialization/deserialization.
|
Package yaml is an indirection to handle YAML serialization/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]. |
|
fdleak
Package fdleak provides file descriptor leak detection.
|
Package fdleak provides file descriptor leak detection. |
|
leak
Package leak provide goroutine leak detection using pprof labels instead of stack-trace heuristics.
|
Package leak provide goroutine leak detection using pprof labels instead of stack-trace heuristics. |
|
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. |