A minimalist Go testing helper providing simple assertions, golden file testing, and no dependencies.
Be is a minimalist Go testing package that provides a straightforward set of assertion helpers to simplify test writing. It focuses on reducing boilerplate and enabling clear, maintainable tests with built-in support for common patterns like equality checks, error handling, and golden file comparisons, all while keeping dependencies to zero.
Go developers who prefer minimal, dependency-free testing tools and want to reduce repetitive boilerplate in their test suites. It's particularly suited for those writing unit tests that require simple assertions, error checks, and file-based comparisons.
Developers choose Be for its simplicity, zero dependencies, and fail-fast default behavior, which prioritizes quick, quiet failures with line-number references over verbose error messages. It offers type-safe assertions using Go generics and encourages custom helpers for advanced cases, making it a lightweight alternative to more complex testing frameworks.
The Go test helper for minimalists
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Relies solely on the Go standard library, ensuring the package is lightweight and avoids version conflicts, as emphasized in the README's 'No dependencies' feature.
Uses Go generics for functions like be.Equal and be.AllEqual, providing compile-time type safety for comparable types and slices, reducing runtime errors.
The testfile subpackage offers built-in tools for golden file testing, automatically comparing outputs and updating files with environmental variables, simplifying file-based tests.
Helpers like be.NilErr and be.Nonzero streamline common error validation, reducing boilerplate code for testing error conditions, as shown in the README examples.
The README explicitly states that for advanced cases, developers must write custom helpers using be.True, which can increase development time and lead to inconsistent test code across teams.
By design, failures provide only line-number references without verbose messages, making it harder to diagnose complex failures without additional logging or comments, as noted in the philosophy section.
Be focuses solely on assertions, so for tests requiring mock objects or stubs, developers must integrate other packages, adding complexity to the test setup beyond its scope.