📖 2 min read (~ 300 words).

Common

Other Uncategorized Helpers

Assertions

GoDoc

All links point to https://pkg.go.dev/github.com/go-openapi/testify/v2

This domain exposes 4 functionalities.


Other helpers

CallerInfo

CallerInfo returns an array of strings containing the file and line number of each stack frame leading from the current test to the assert call that failed.

SignatureUsage
assert.CallerInfo() []stringpackage-level function
SignatureUsage
require.CallerInfo() []stringpackage-level function
SignatureUsage
assertions.CallerInfo() []stringinternal implementation

Source: github.com/go-openapi/testify/v2/internal/assertions#CallerInfo

Maintainer Note

it is not necessary to export CallerInfo. This should remain an internal implementation detail.

ObjectsAreEqual

ObjectsAreEqual determines if two objects are considered equal.

This function does no assertion of any kind.

ObjectsAreEqualValues

ObjectsAreEqualValues gets whether two objects are equal, or if their values are equal.

WithHunkSize

WithHunkSize sets how many unchanged lines the diff shows around each change.

The diff appears in the failure message of Equal, EqualT, EqualValues, EqualExportedValues and Exactly, whenever both values are a struct, map, slice, array or string. The default is 1. A value below 1 is clamped to 1, and a value larger than the rendered value prints it whole.

Pass it to New, which is the only place options are read:

a := assert.New(t, assert.WithHunkSize(4))
a.Equal(expected, actual)
SignatureUsage
assert.WithHunkSize(n int) Optionpackage-level function
SignatureUsage
require.WithHunkSize(n int) Optionpackage-level function

Generated with github.com/go-openapi/testify/codegen/v2