blob: c9dccc4d6cd0aad89a9ecf638d8cde1ea043a37a [file] [log] [blame]
Andrea Campanella7167ebb2020-02-24 09:56:38 +01001// Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.
2//
3// Example Usage
4//
5// The following is a complete example using assert in a standard test function:
6// import (
7// "testing"
8// "github.com/stretchr/testify/assert"
9// )
10//
11// func TestSomething(t *testing.T) {
12//
13// var a string = "Hello"
14// var b string = "Hello"
15//
16// assert.Equal(t, a, b, "The two words should be the same.")
17//
18// }
19//
20// if you assert many times, use the format below:
21//
22// import (
23// "testing"
24// "github.com/stretchr/testify/assert"
25// )
26//
27// func TestSomething(t *testing.T) {
28// assert := assert.New(t)
29//
30// var a string = "Hello"
31// var b string = "Hello"
32//
33// assert.Equal(a, b, "The two words should be the same.")
34// }
35//
36// Assertions
37//
38// Assertions allow you to easily write test code, and are global funcs in the `assert` package.
39// All assertion functions take, as the first argument, the `*testing.T` object provided by the
40// testing framework. This allows the assertion funcs to write the failings and other details to
41// the correct place.
42//
43// Every assertion function also takes an optional string message as the final argument,
44// allowing custom error messages to be appended to the message the assertion method outputs.
45package assert