blob: c8e3f94a8034a8b7968d7b09d3b21b3119b1fd10 [file] [log] [blame]
Abhay Kumara61c5222025-11-10 07:32:50 +00001// Package require implements the same assertions as the `assert` package but
2// stops test execution when a test fails.
3//
4// # Example Usage
5//
6// The following is a complete example using require in a standard test function:
7//
8// import (
9// "testing"
10// "github.com/stretchr/testify/require"
11// )
12//
13// func TestSomething(t *testing.T) {
14//
15// var a string = "Hello"
16// var b string = "Hello"
17//
18// require.Equal(t, a, b, "The two words should be the same.")
19//
20// }
21//
22// # Assertions
23//
24// The `require` package have same global functions as in the `assert` package,
25// but instead of returning a boolean result they call `t.FailNow()`.
26// A consequence of this is that it must be called from the goroutine running
27// the test function, not from other goroutines created during the test.
28//
29// Every assertion function also takes an optional string message as the final argument,
30// allowing custom error messages to be appended to the message the assertion method outputs.
31package require