Documentation ¶
Overview ¶
Package gocheckext provides extensions for github.com/go-check/check.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DeepLogErrors is a value for github.com/go-test/deep.LogErrors // while DeepEqualsPP. // In tests it's better to know when your DeepEqual check skip to // compare something. DeepLogErrors = true // DeepCompareUnexportedFields is a value for // github.com/go-test/deep.CompareUnexportedFields while DeepEqualsPP. // In tests it's usual to compare unexported fields. DeepCompareUnexportedFields = true )
var DeepEqualsPP = NewCountingChecker( "DeepEqualsPP", []string{"obtained", "expected"}, deepEquals, )
DeepEqualsPP works like gocheck's DeepEquals but also pretty-print a list of differences.
You can easily make all your current tests use DeepEqualsPP with:
func init() { DeepEquals = gocheckext.DeepEqualsPP }
Functions ¶
func CountChecker ¶
func CountChecker(f check.Checker) check.Checker
CountChecker wrap usual Checker to count it calls. You should use it to wrap all your custom (not gocheck's ones) checkers. Example:
import . "github.com/dropbox/godropbox/gocheck2" // wrap custom checker var myChecker = gocheckext.CountChecker(myCheckerType{…}) func init() { // wrap checkers imported from godropbox AlmostEqual = gocheckext.CountChecker(AlmostEqual) BytesEquals = gocheckext.CountChecker(BytesEquals) GreaterThan = gocheckext.CountChecker(GreaterThan) ... }
func CountingTestingT ¶
CountingTestingT should be called instead of gocheck's TestingT. It will report count of executed checks (like DeepEquals or IsNil) after usual TestingT report of passed/failed tests - so you can see how many real tests you've implemented so far.
func Test(t *testing.T) { gocheckext.CountingTestingT(t) }
Then run `go test` as usually and you'll see count of checks after count of tests, for ex.:
OK: 21 passed, 3 skipped Checks: 197 --- PASS: Test (0.49s)
func NewChecker ¶
NewChecker makes it easier to define your own checkers.
func NewCountingChecker ¶
NewCountingChecker is just a convenient shortcut for CountChecker(NewChecker(…)).