Helpers to complement Go testing package
Helpers to complement Go testing
package.
Write tests with ease and fun!
This package is like
testify/assert
on steroids. :)
*testing.T
methods and doesn’t introduce newJust wrap each (including subtests) *testing.T
using check.T()
and write
tests as usually with testing package. Call new methods provided by this
package to have more clean/concise test code and cool dump/diff.
import "github.com/powerman/check"
func TestSomething(tt *testing.T) {
t := check.T(tt)
t.Equal(2, 2)
t.Log("You can use new t just like usual *testing.T")
t.Run("Subtests/Parallel example", func(tt *testing.T) {
t := check.T(tt)
t.Parallel()
t.NotEqual(2, 3, "should not be 3!")
obj, err := NewObj()
if t.Nil(err) {
t.Match(obj.field, `^\d+$`)
}
})
}
To get optional statistics about executed checkers add:
func TestMain(m *testing.M) { check.TestMain(m) }
When use goconvey tool, to get nice diff in web UI
add:
import _ "github.com/smartystreets/goconvey/convey"
Require Go 1.9.
go get github.com/powerman/check
goconvey
diff looks like.string
/[]byte
?Skip
, Skipf
, SkipNow
)?t:=check.T(tt)
- try to intercept Run()
and
`Parallel()` for detecting using wrong `t` (looks like golangci-lint's
tparallel catch at least `Parallel()` case).