doc.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // 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. //
  7. // import (
  8. // "testing"
  9. // "github.com/stretchr/testify/assert"
  10. // )
  11. //
  12. // func TestSomething(t *testing.T) {
  13. //
  14. // var a string = "Hello"
  15. // var b string = "Hello"
  16. //
  17. // assert.Equal(t, a, b, "The two words should be the same.")
  18. //
  19. // }
  20. //
  21. // if you assert many times, use the format below:
  22. //
  23. // import (
  24. // "testing"
  25. // "github.com/stretchr/testify/assert"
  26. // )
  27. //
  28. // func TestSomething(t *testing.T) {
  29. // assert := assert.New(t)
  30. //
  31. // var a string = "Hello"
  32. // var b string = "Hello"
  33. //
  34. // assert.Equal(a, b, "The two words should be the same.")
  35. // }
  36. //
  37. // # Assertions
  38. //
  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.
  46. package assert