doc.go raw

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