top

Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.

Example Usage

The following is a complete example using assert in a standard test function:

import (
  "testing"
  "github.com/stretchr/testify/assert"
)

func TestSomething(t *testing.T) {

  var a string = "Hello"
  var b string = "Hello"

  assert.Equal(t, a, b, "The two words should be the same.")

}

if you assert many times, use the format below:

import (
  "testing"
  "github.com/stretchr/testify/assert"
)

func TestSomething(t *testing.T) {
  assert := assert.New(t)

  var a string = "Hello"
  var b string = "Hello"

  assert.Equal(a, b, "The two words should be the same.")
}

Assertions

Assertions allow you to easily write test code, and are global funcs in the `assert` package. All assertion functions take, as the first argument, the `*testing.T` object provided by the testing framework. This allows the assertion funcs to write the failings and other details to the correct place.

Every assertion function also takes an optional string message as the final argument, allowing custom error messages to be appended to the message the assertion method outputs.

Imported by 2 package(s)

  1. github.com/jcelliott/testify/mock
  2. github.com/omakoto/mlib/mtest

Imported only in test by 96 package(s)

  1. github.com/0x6e6562/gosnow
  2. github.com/AnimationMentor/turnpike
  3. github.com/DramaFever/go-diff/diffmatchpatch
  4. github.com/Jamie-McCaw/Go-TicTacToe/tictactoe
  5. github.com/SpirentOrion/turnpike
  6. github.com/ThatRubenAguilar/go-sitemaps/datastore
  7. github.com/ThatRubenAguilar/go-sitemaps/sitemap
  8. github.com/ThatRubenAguilar/go-sitemaps/util
  9. github.com/ThomsonReutersEikon/gofreetds
  10. github.com/agileknight/go-diff/diffmatchpatch
  11. github.com/ahare/gofreetds
  12. github.com/alecthomas/binary
  13. github.com/alecthomas/expr
  14. github.com/alecthomas/flagutil
  15. github.com/alecthomas/mph
  16. github.com/alecthomas/multiplex
  17. github.com/alecthomas/tuplespace
  18. github.com/alecthomas/tuplespace/service
  19. github.com/alecthomas/unsafeslice
  20. github.com/alecthomas/webservice
  21. github.com/andreynering/go-diff/diffmatchpatch
  22. github.com/apesternikov/gossie/src/gossie
  23. github.com/artpar/go-diff/diffmatchpatch
  24. github.com/bcurren/turnpike
  25. github.com/beyang/binary
  26. github.com/brycereitano/gomeboycolor/inputoutput
  27. github.com/ctaintor/go-bikeme/bikeshareservice
  28. github.com/cvanderschuere/turnpike
  29. github.com/davidmz/kingpin
  30. github.com/digitallumens/turnpike
  31. github.com/djhworld/gomeboycolor/src/inputoutput
  32. github.com/dobyrch/termboy-go/inputoutput
  33. github.com/e8vm/shanhu/dmp
  34. github.com/eggheadgames/xoauth
  35. github.com/erans/gosnowflake
  36. github.com/fanngyuan/gosnowflake
  37. github.com/fernandez14/turnpike
  38. github.com/freehaha/goweb/controllers
  39. github.com/freehaha/goweb/handlers
  40. github.com/freehaha/goweb/paths
  41. github.com/freehaha/goweb/responders
  42. github.com/freehaha/goweb/webcontext
  43. github.com/georgethomas111/go-rest
  44. github.com/gonuts/binary
  45. github.com/gordonklaus/go-diff/diffmatchpatch
  46. github.com/gtczap/gofreetds
  47. github.com/h8liu/go-diff/dmp
  48. github.com/hailocab/go-diff/diffmatchpatch
  49. github.com/highway900/turnpike
  50. github.com/huuzkee-foundation/gosnow
  51. github.com/huuzkee-foundation/gosnowflake
  52. github.com/iancmcc/gosnow
  53. github.com/imkira/kingpin
  54. github.com/ivahaev/turnpike
  55. github.com/iwot/go-util/util
  56. github.com/iwot/webtool
  57. github.com/jabgibson/go-diff/diffmatchpatch
  58. github.com/jba/go-diff/diffmatchpatch
  59. github.com/jkassemi/gosnow
  60. github.com/jneander/tic-tac-toe-go/ttt
  61. github.com/juliendsv/gosnow
  62. github.com/kykl/gosnow
  63. github.com/lanior/scheme
  64. github.com/lujiacn/go-R/R
  65. github.com/marshauf/turnpike
  66. github.com/mattbaird/turnpike
  67. github.com/maxekman/turnpike
  68. github.com/mt-huerta/turnpike
  69. github.com/nchern/go-R/R
  70. github.com/nyxtom/kingpin
  71. github.com/omakoto/go-diff/diffmatchpatch
  72. github.com/omakoto/mlib/shell
  73. github.com/op/go-diff/diffmatchpatch
  74. github.com/postfix/expr
  75. github.com/sdming/gosnow
  76. github.com/sergi/go-diff/diffmatchpatch
  77. github.com/sesteel/go-diff/diffmatchpatch
  78. github.com/shatrugna/go-diff/diffmatchpatch
  79. github.com/shingara/goup/request
  80. github.com/sorbits/go.enmime
  81. github.com/sushimako/go-diff/diffmatchpatch
  82. github.com/thatguystone/gofreetds
  83. github.com/tleyden/kingpin
  84. github.com/tmaiaroto/gosnow
  85. github.com/videolabs/gosnow
  86. github.com/whispermemory/unsafeslice
  87. github.com/wurkhappy/go-diff/diffmatchpatch
  88. github.com/xiaoyu830411/gosnowflake
  89. github.com/ympons/expr
  90. github.com/zaybiz/kingpin
  91. github.com/zimmski/go-diff/diffmatchpatch
  92. gopkg.in/alecthomas/kingpin.v0
  93. gopkg.in/devtable/turnpike.v1
  94. gopkg.in/jcelliott/turnpike.v1
  95. gopkg.in/quantum/turnpike.v1
  96. gopkg.in/webee/turnpike.v1

Imports 2 package(s)

  1. github.com/davecgh/go-spew/spew
  2. github.com/pmezard/go-difflib/difflib