package
1.10.0
Repository: https://github.com/stretchr/testify.git
Documentation: pkg.go.dev

# Functions

Condition uses a Comparison to assert a complex condition.
Conditionf uses a Comparison to assert a complex condition.
Contains asserts that the specified string, list(array, slice...) or map contains the specified substring or element.
Containsf asserts that the specified string, list(array, slice...) or map contains the specified substring or element.
DirExists checks whether a directory exists in the given path.
DirExistsf checks whether a directory exists in the given path.
ElementsMatch asserts that the specified listA(array, slice...) is equal to specified listB(array, slice...) ignoring the order of the elements.
ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified listB(array, slice...) ignoring the order of the elements.
Empty asserts that the specified object is empty.
Emptyf asserts that the specified object is empty.
Equal asserts that two objects are equal.
EqualError asserts that a function returned an error (i.e.
EqualErrorf asserts that a function returned an error (i.e.
EqualExportedValues asserts that the types of two objects are equal and their public fields are also equal.
EqualExportedValuesf asserts that the types of two objects are equal and their public fields are also equal.
Equalf asserts that two objects are equal.
EqualValues asserts that two objects are equal or convertible to the larger type and equal.
EqualValuesf asserts that two objects are equal or convertible to the larger type and equal.
Error asserts that a function returned an error (i.e.
ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
ErrorAsf asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
ErrorContains asserts that a function returned an error (i.e.
ErrorContainsf asserts that a function returned an error (i.e.
Errorf asserts that a function returned an error (i.e.
ErrorIs asserts that at least one of the errors in err's chain matches target.
ErrorIsf asserts that at least one of the errors in err's chain matches target.
Eventually asserts that given condition will be met in waitFor time, periodically checking target function each tick.
Eventuallyf asserts that given condition will be met in waitFor time, periodically checking target function each tick.
EventuallyWithT asserts that given condition will be met in waitFor time, periodically checking target function each tick.
EventuallyWithTf asserts that given condition will be met in waitFor time, periodically checking target function each tick.
Exactly asserts that two objects are equal in value and type.
Exactlyf asserts that two objects are equal in value and type.
Fail reports a failure through.
Failf reports a failure through.
FailNow fails test.
FailNowf fails test.
False asserts that the specified value is false.
Falsef asserts that the specified value is false.
FileExists checks whether a file exists in the given path.
FileExistsf checks whether a file exists in the given path.
Greater asserts that the first element is greater than the second require.Greater(t, 2, 1) require.Greater(t, float64(2), float64(1)) require.Greater(t, "b", "a").
Greaterf asserts that the first element is greater than the second require.Greaterf(t, 2, 1, "error message %s", "formatted") require.Greaterf(t, float64(2), float64(1), "error message %s", "formatted") require.Greaterf(t, "b", "a", "error message %s", "formatted").
GreaterOrEqual asserts that the first element is greater than or equal to the second require.GreaterOrEqual(t, 2, 1) require.GreaterOrEqual(t, 2, 2) require.GreaterOrEqual(t, "b", "a") require.GreaterOrEqual(t, "b", "b").
GreaterOrEqualf asserts that the first element is greater than or equal to the second require.GreaterOrEqualf(t, 2, 1, "error message %s", "formatted") require.GreaterOrEqualf(t, 2, 2, "error message %s", "formatted") require.GreaterOrEqualf(t, "b", "a", "error message %s", "formatted") require.GreaterOrEqualf(t, "b", "b", "error message %s", "formatted").
HTTPBodyContains asserts that a specified handler returns a body that contains a string.
HTTPBodyContainsf asserts that a specified handler returns a body that contains a string.
HTTPBodyNotContains asserts that a specified handler returns a body that does not contain a string.
HTTPBodyNotContainsf asserts that a specified handler returns a body that does not contain a string.
HTTPError asserts that a specified handler returns an error status code.
HTTPErrorf asserts that a specified handler returns an error status code.
HTTPRedirect asserts that a specified handler returns a redirect status code.
HTTPRedirectf asserts that a specified handler returns a redirect status code.
HTTPStatusCode asserts that a specified handler returns a specified status code.
HTTPStatusCodef asserts that a specified handler returns a specified status code.
HTTPSuccess asserts that a specified handler returns a success status code.
HTTPSuccessf asserts that a specified handler returns a success status code.
Implements asserts that an object is implemented by the specified interface.
Implementsf asserts that an object is implemented by the specified interface.
InDelta asserts that the two numerals are within delta of each other.
InDeltaf asserts that the two numerals are within delta of each other.
InDeltaMapValues is the same as InDelta, but it compares all values between two maps.
InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps.
InDeltaSlice is the same as InDelta, except it compares two slices.
InDeltaSlicef is the same as InDelta, except it compares two slices.
InEpsilon asserts that expected and actual have a relative error less than epsilon.
InEpsilonf asserts that expected and actual have a relative error less than epsilon.
InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
IsDecreasing asserts that the collection is decreasing require.IsDecreasing(t, []int{2, 1, 0}) require.IsDecreasing(t, []float{2, 1}) require.IsDecreasing(t, []string{"b", "a"}).
IsDecreasingf asserts that the collection is decreasing require.IsDecreasingf(t, []int{2, 1, 0}, "error message %s", "formatted") require.IsDecreasingf(t, []float{2, 1}, "error message %s", "formatted") require.IsDecreasingf(t, []string{"b", "a"}, "error message %s", "formatted").
IsIncreasing asserts that the collection is increasing require.IsIncreasing(t, []int{1, 2, 3}) require.IsIncreasing(t, []float{1, 2}) require.IsIncreasing(t, []string{"a", "b"}).
IsIncreasingf asserts that the collection is increasing require.IsIncreasingf(t, []int{1, 2, 3}, "error message %s", "formatted") require.IsIncreasingf(t, []float{1, 2}, "error message %s", "formatted") require.IsIncreasingf(t, []string{"a", "b"}, "error message %s", "formatted").
IsNonDecreasing asserts that the collection is not decreasing require.IsNonDecreasing(t, []int{1, 1, 2}) require.IsNonDecreasing(t, []float{1, 2}) require.IsNonDecreasing(t, []string{"a", "b"}).
IsNonDecreasingf asserts that the collection is not decreasing require.IsNonDecreasingf(t, []int{1, 1, 2}, "error message %s", "formatted") require.IsNonDecreasingf(t, []float{1, 2}, "error message %s", "formatted") require.IsNonDecreasingf(t, []string{"a", "b"}, "error message %s", "formatted").
IsNonIncreasing asserts that the collection is not increasing require.IsNonIncreasing(t, []int{2, 1, 1}) require.IsNonIncreasing(t, []float{2, 1}) require.IsNonIncreasing(t, []string{"b", "a"}).
IsNonIncreasingf asserts that the collection is not increasing require.IsNonIncreasingf(t, []int{2, 1, 1}, "error message %s", "formatted") require.IsNonIncreasingf(t, []float{2, 1}, "error message %s", "formatted") require.IsNonIncreasingf(t, []string{"b", "a"}, "error message %s", "formatted").
IsType asserts that the specified objects are of the same type.
IsTypef asserts that the specified objects are of the same type.
JSONEq asserts that two JSON strings are equivalent.
JSONEqf asserts that two JSON strings are equivalent.
Len asserts that the specified object has specific length.
Lenf asserts that the specified object has specific length.
Less asserts that the first element is less than the second require.Less(t, 1, 2) require.Less(t, float64(1), float64(2)) require.Less(t, "a", "b").
Lessf asserts that the first element is less than the second require.Lessf(t, 1, 2, "error message %s", "formatted") require.Lessf(t, float64(1), float64(2), "error message %s", "formatted") require.Lessf(t, "a", "b", "error message %s", "formatted").
LessOrEqual asserts that the first element is less than or equal to the second require.LessOrEqual(t, 1, 2) require.LessOrEqual(t, 2, 2) require.LessOrEqual(t, "a", "b") require.LessOrEqual(t, "b", "b").
LessOrEqualf asserts that the first element is less than or equal to the second require.LessOrEqualf(t, 1, 2, "error message %s", "formatted") require.LessOrEqualf(t, 2, 2, "error message %s", "formatted") require.LessOrEqualf(t, "a", "b", "error message %s", "formatted") require.LessOrEqualf(t, "b", "b", "error message %s", "formatted").
Negative asserts that the specified element is negative require.Negative(t, -1) require.Negative(t, -1.23).
Negativef asserts that the specified element is negative require.Negativef(t, -1, "error message %s", "formatted") require.Negativef(t, -1.23, "error message %s", "formatted").
Never asserts that the given condition doesn't satisfy in waitFor time, periodically checking the target function each tick.
Neverf asserts that the given condition doesn't satisfy in waitFor time, periodically checking the target function each tick.
New makes a new Assertions object for the specified TestingT.
Nil asserts that the specified object is nil.
Nilf asserts that the specified object is nil.
NoDirExists checks whether a directory does not exist in the given path.
NoDirExistsf checks whether a directory does not exist in the given path.
NoError asserts that a function returned no error (i.e.
NoErrorf asserts that a function returned no error (i.e.
NoFileExists checks whether a file does not exist in a given path.
NoFileExistsf checks whether a file does not exist in a given path.
NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the specified substring or element.
NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the specified substring or element.
NotElementsMatch asserts that the specified listA(array, slice...) is NOT equal to specified listB(array, slice...) ignoring the order of the elements.
NotElementsMatchf asserts that the specified listA(array, slice...) is NOT equal to specified listB(array, slice...) ignoring the order of the elements.
NotEmpty asserts that the specified object is NOT empty.
NotEmptyf asserts that the specified object is NOT empty.
NotEqual asserts that the specified values are NOT equal.
NotEqualf asserts that the specified values are NOT equal.
NotEqualValues asserts that two objects are not equal even when converted to the same type require.NotEqualValues(t, obj1, obj2).
NotEqualValuesf asserts that two objects are not equal even when converted to the same type require.NotEqualValuesf(t, obj1, obj2, "error message %s", "formatted").
NotErrorAs asserts that none of the errors in err's chain matches target, but if so, sets target to that error value.
NotErrorAsf asserts that none of the errors in err's chain matches target, but if so, sets target to that error value.
NotErrorIs asserts that none of the errors in err's chain matches target.
NotErrorIsf asserts that none of the errors in err's chain matches target.
NotImplements asserts that an object does not implement the specified interface.
NotImplementsf asserts that an object does not implement the specified interface.
NotNil asserts that the specified object is not nil.
NotNilf asserts that the specified object is not nil.
NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
NotRegexp asserts that a specified regexp does not match a string.
NotRegexpf asserts that a specified regexp does not match a string.
NotSame asserts that two pointers do not reference the same object.
NotSamef asserts that two pointers do not reference the same object.
NotSubset asserts that the specified list(array, slice...) or map does NOT contain all elements given in the specified subset list(array, slice...) or map.
NotSubsetf asserts that the specified list(array, slice...) or map does NOT contain all elements given in the specified subset list(array, slice...) or map.
NotZero asserts that i is not the zero value for its type.
NotZerof asserts that i is not the zero value for its type.
Panics asserts that the code inside the specified PanicTestFunc panics.
Panicsf asserts that the code inside the specified PanicTestFunc panics.
PanicsWithError asserts that the code inside the specified PanicTestFunc panics, and that the recovered panic value is an error that satisfies the EqualError comparison.
PanicsWithErrorf asserts that the code inside the specified PanicTestFunc panics, and that the recovered panic value is an error that satisfies the EqualError comparison.
PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that the recovered panic value equals the expected panic value.
PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that the recovered panic value equals the expected panic value.
Positive asserts that the specified element is positive require.Positive(t, 1) require.Positive(t, 1.23).
Positivef asserts that the specified element is positive require.Positivef(t, 1, "error message %s", "formatted") require.Positivef(t, 1.23, "error message %s", "formatted").
Regexp asserts that a specified regexp matches a string.
Regexpf asserts that a specified regexp matches a string.
Same asserts that two pointers reference the same object.
Samef asserts that two pointers reference the same object.
Subset asserts that the specified list(array, slice...) or map contains all elements given in the specified subset list(array, slice...) or map.
Subsetf asserts that the specified list(array, slice...) or map contains all elements given in the specified subset list(array, slice...) or map.
True asserts that the specified value is true.
Truef asserts that the specified value is true.
WithinDuration asserts that the two times are within duration delta of each other.
WithinDurationf asserts that the two times are within duration delta of each other.
WithinRange asserts that a time is within a time range (inclusive).
WithinRangef asserts that a time is within a time range (inclusive).
YAMLEq asserts that two YAML strings are equivalent.
YAMLEqf asserts that two YAML strings are equivalent.
Zero asserts that i is the zero value for its type.
Zerof asserts that i is the zero value for its type.

# Structs

Assertions provides assertion methods around the TestingT interface.

# Interfaces

TestingT is an interface wrapper around *testing.T.

# Type aliases

BoolAssertionFunc is a common function prototype when validating a bool value.
ComparisonAssertionFunc is a common function prototype when comparing two values.
ErrorAssertionFunc is a common function prototype when validating an error value.
ValueAssertionFunc is a common function prototype when validating a single value.