1
0

doc.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. // 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.
  45. package assert