Blame vendor/github.com/stretchr/testify/assert/doc.go

Packit 63bb0d
// Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.
Packit 63bb0d
//
Packit 63bb0d
// Example Usage
Packit 63bb0d
//
Packit 63bb0d
// The following is a complete example using assert in a standard test function:
Packit 63bb0d
//    import (
Packit 63bb0d
//      "testing"
Packit 63bb0d
//      "github.com/stretchr/testify/assert"
Packit 63bb0d
//    )
Packit 63bb0d
//
Packit 63bb0d
//    func TestSomething(t *testing.T) {
Packit 63bb0d
//
Packit 63bb0d
//      var a string = "Hello"
Packit 63bb0d
//      var b string = "Hello"
Packit 63bb0d
//
Packit 63bb0d
//      assert.Equal(t, a, b, "The two words should be the same.")
Packit 63bb0d
//
Packit 63bb0d
//    }
Packit 63bb0d
//
Packit 63bb0d
// if you assert many times, use the format below:
Packit 63bb0d
//
Packit 63bb0d
//    import (
Packit 63bb0d
//      "testing"
Packit 63bb0d
//      "github.com/stretchr/testify/assert"
Packit 63bb0d
//    )
Packit 63bb0d
//
Packit 63bb0d
//    func TestSomething(t *testing.T) {
Packit 63bb0d
//      assert := assert.New(t)
Packit 63bb0d
//
Packit 63bb0d
//      var a string = "Hello"
Packit 63bb0d
//      var b string = "Hello"
Packit 63bb0d
//
Packit 63bb0d
//      assert.Equal(a, b, "The two words should be the same.")
Packit 63bb0d
//    }
Packit 63bb0d
//
Packit 63bb0d
// Assertions
Packit 63bb0d
//
Packit 63bb0d
// Assertions allow you to easily write test code, and are global funcs in the `assert` package.
Packit 63bb0d
// All assertion functions take, as the first argument, the `*testing.T` object provided by the
Packit 63bb0d
// testing framework. This allows the assertion funcs to write the failings and other details to
Packit 63bb0d
// the correct place.
Packit 63bb0d
//
Packit 63bb0d
// Every assertion function also takes an optional string message as the final argument,
Packit 63bb0d
// allowing custom error messages to be appended to the message the assertion method outputs.
Packit 63bb0d
package assert