doc.go 856 B

1234567891011121314151617181920212223242526272829
  1. // Package require implements the same assertions as the `assert` package but
  2. // stops test execution when a test fails.
  3. //
  4. // # Example Usage
  5. //
  6. // The following is a complete example using require in a standard test function:
  7. //
  8. // import (
  9. // "testing"
  10. // "github.com/stretchr/testify/require"
  11. // )
  12. //
  13. // func TestSomething(t *testing.T) {
  14. //
  15. // var a string = "Hello"
  16. // var b string = "Hello"
  17. //
  18. // require.Equal(t, a, b, "The two words should be the same.")
  19. //
  20. // }
  21. //
  22. // # Assertions
  23. //
  24. // The `require` package have same global functions as in the `assert` package,
  25. // but instead of returning a boolean result they call `t.FailNow()`.
  26. //
  27. // Every assertion function also takes an optional string message as the final argument,
  28. // allowing custom error messages to be appended to the message the assertion method outputs.
  29. package require