Documentation ¶
Index ¶
- func AssertErrorContents(t *testing.T, theError error, contains []string, msgAndArgs ...interface{}) bool
- func AssertNotPanicsNoError(t *testing.T, f func() error, msgAndArgs ...interface{}) bool
- func AssertPanicContents(t *testing.T, contains []string, f assert.PanicTestFunc, ...) bool
- func AssertPanicsWithMessage(t *testing.T, expected string, f assert.PanicTestFunc, ...) bool
- func RequireNotPanicsNoError(t *testing.T, f func() error, msgAndArgs ...interface{})
- func RequirePanicContents(t *testing.T, contains []string, f assert.PanicTestFunc, ...)
- func RequirePanicsWithMessage(t *testing.T, expected string, f assert.PanicTestFunc, ...)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertErrorContents ¶
func AssertErrorContents(t *testing.T, theError error, contains []string, msgAndArgs ...interface{}) bool
AssertErrorContents asserts that, if contains is empty, there's no error. Otherwise, asserts that there is an error, and that it contains each of the provided strings.
func AssertNotPanicsNoError ¶
AssertNotPanicsNoError asserts that the code inside the provided function does not panic and that it does not return an error. Returns true if it neither panics nor errors.
func AssertPanicContents ¶
func AssertPanicContents(t *testing.T, contains []string, f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
AssertPanicContents asserts that, if contains is empty, the provided func does not panic Otherwise, asserts that the func panics and that its panic message contains each of the provided strings.
func AssertPanicsWithMessage ¶
func AssertPanicsWithMessage(t *testing.T, expected string, f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
AssertPanicsWithMessage asserts that the code inside the specified PanicTestFunc panics, and that the recovered panic message equals the expected panic message.
AssertPanicsWithMessage(t, "crazy error", func(){ GoCrazy() })
PanicsWithValue requires a specific interface{} value to be provided, which can be problematic. PanicsWithError requires that the panic value is an error. This one uses fmt.Sprintf("%v", panicValue) to convert the panic recovery value to a string to test against.
func RequireNotPanicsNoError ¶
RequireNotPanicsNoError asserts that the code inside the provided function does not panic and that it does not return an error.
If the assertion fails, the test is halted.
func RequirePanicContents ¶
func RequirePanicContents(t *testing.T, contains []string, f assert.PanicTestFunc, msgAndArgs ...interface{})
RequirePanicContents asserts that, if contains is empty, the provided func does not panic Otherwise, asserts that the func panics and that its panic message contains each of the provided strings.
If the assertion fails, the test is halted.
func RequirePanicsWithMessage ¶
func RequirePanicsWithMessage(t *testing.T, expected string, f assert.PanicTestFunc, msgAndArgs ...interface{})
RequirePanicsWithMessage asserts that the code inside the specified PanicTestFunc panics, and that the recovered panic message equals the expected panic message.
RequirePanicsWithMessage(t, "crazy error", func(){ GoCrazy() })
PanicsWithValue requires a specific interface{} value to be provided, which can be problematic. PanicsWithError requires that the panic value is an error. This one uses fmt.Sprintf("%v", panicValue) to convert the panic recovery value to a string to test against.
If the assertion fails, the test is halted.
Types ¶
This section is empty.