📖 4 min read (~ 800 words).

Type

Asserting Types Rather Than Values

Assertions

GoDoc

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

This domain exposes 6 functionalities.

Implements

Implements asserts that an object is implemented by the specified interface.

Examples
	assertions.Implements(t, (*MyInterface)(nil), new(MyObject))
	success: ptr(dummyInterface), new(testing.T)
	failure: (*error)(nil), new(testing.T)

IsNotType

IsNotType asserts that the specified objects are not of the same type.

Examples
	assertions.IsNotType(t, &NotMyStruct{}, &MyStruct{})
	success: int32(123), int64(456)
	failure: 123, 456

IsType

IsType asserts that the specified objects are of the same type.

Examples
	assertions.IsType(t, &MyStruct{}, &MyStruct{})
	success: 123, 456
	failure: int32(123), int64(456)

NotImplements

NotImplements asserts that an object does not implement the specified interface.

Examples
	assertions.NotImplements(t, (*MyInterface)(nil), new(MyObject))
	success: (*error)(nil), new(testing.T)
	failure: ptr(dummyInterface), new(testing.T)

NotZero

NotZero asserts that i is not the zero value for its type.

Examples
	assertions.NotZero(t, obj)
	success: 1
	failure: 0

Zero

Zero asserts that i is the zero value for its type.

Examples
	assertions.Zero(t, obj)
	success: 0
	failure: 1


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