blob: 4953981d38780794a415aeaf9091e1174634326e [file] [log] [blame]
kesavandb9f54fd2021-11-25 20:08:04 +05301// Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.
2//
Akash Reddy Kankanalad9ec4822025-06-10 22:59:53 +05303// # Example Usage
kesavandb9f54fd2021-11-25 20:08:04 +05304//
5// The following is a complete example using assert in a standard test function:
kesavandb9f54fd2021-11-25 20:08:04 +05306//
Akash Reddy Kankanalad9ec4822025-06-10 22:59:53 +05307// import (
8// "testing"
9// "github.com/stretchr/testify/assert"
10// )
kesavandb9f54fd2021-11-25 20:08:04 +053011//
Akash Reddy Kankanalad9ec4822025-06-10 22:59:53 +053012// func TestSomething(t *testing.T) {
kesavandb9f54fd2021-11-25 20:08:04 +053013//
Akash Reddy Kankanalad9ec4822025-06-10 22:59:53 +053014// var a string = "Hello"
15// var b string = "Hello"
kesavandb9f54fd2021-11-25 20:08:04 +053016//
Akash Reddy Kankanalad9ec4822025-06-10 22:59:53 +053017// assert.Equal(t, a, b, "The two words should be the same.")
18//
19// }
kesavandb9f54fd2021-11-25 20:08:04 +053020//
21// if you assert many times, use the format below:
22//
Akash Reddy Kankanalad9ec4822025-06-10 22:59:53 +053023// import (
24// "testing"
25// "github.com/stretchr/testify/assert"
26// )
kesavandb9f54fd2021-11-25 20:08:04 +053027//
Akash Reddy Kankanalad9ec4822025-06-10 22:59:53 +053028// func TestSomething(t *testing.T) {
29// assert := assert.New(t)
kesavandb9f54fd2021-11-25 20:08:04 +053030//
Akash Reddy Kankanalad9ec4822025-06-10 22:59:53 +053031// var a string = "Hello"
32// var b string = "Hello"
kesavandb9f54fd2021-11-25 20:08:04 +053033//
Akash Reddy Kankanalad9ec4822025-06-10 22:59:53 +053034// assert.Equal(a, b, "The two words should be the same.")
35// }
kesavandb9f54fd2021-11-25 20:08:04 +053036//
Akash Reddy Kankanalad9ec4822025-06-10 22:59:53 +053037// # Assertions
kesavandb9f54fd2021-11-25 20:08:04 +053038//
39// Assertions allow you to easily write test code, and are global funcs in the `assert` package.
40// All assertion functions take, as the first argument, the `*testing.T` object provided by the
41// testing framework. This allows the assertion funcs to write the failings and other details to
42// the correct place.
43//
44// Every assertion function also takes an optional string message as the final argument,
45// allowing custom error messages to be appended to the message the assertion method outputs.
46package assert