dnscrypt-proxy/vendor/github.com/powerman/check
William Elwood af0629856c Add unit tests for sources.go
Tests cover most of the cache and download related code paths and specify the expected result of various starting states and external failure modes.
Where the current code's behaviour doesn't match a test's expectations, the test is disabled and annotated with a TODO until it can be fixed.
Added dependency on `github.com/powerman/check` and ran `go mod vendor`.
2019-11-08 10:17:12 +01:00
..
.golangci.yml Add unit tests for sources.go 2019-11-08 10:17:12 +01:00
LICENSE Add unit tests for sources.go 2019-11-08 10:17:12 +01:00
README.md Add unit tests for sources.go 2019-11-08 10:17:12 +01:00
check.go Add unit tests for sources.go 2019-11-08 10:17:12 +01:00
color.go Add unit tests for sources.go 2019-11-08 10:17:12 +01:00
color_bsd.go Add unit tests for sources.go 2019-11-08 10:17:12 +01:00
color_linux.go Add unit tests for sources.go 2019-11-08 10:17:12 +01:00
color_other.go Add unit tests for sources.go 2019-11-08 10:17:12 +01:00
color_windows.go Add unit tests for sources.go 2019-11-08 10:17:12 +01:00
doc.go Add unit tests for sources.go 2019-11-08 10:17:12 +01:00
dump.go Add unit tests for sources.go 2019-11-08 10:17:12 +01:00
flags.go Add unit tests for sources.go 2019-11-08 10:17:12 +01:00
go.mod Add unit tests for sources.go 2019-11-08 10:17:12 +01:00
go.sum Add unit tests for sources.go 2019-11-08 10:17:12 +01:00
goconvey.go Add unit tests for sources.go 2019-11-08 10:17:12 +01:00
stats.go Add unit tests for sources.go 2019-11-08 10:17:12 +01:00
util.go Add unit tests for sources.go 2019-11-08 10:17:12 +01:00

README.md

check GoDoc Go Report Card CircleCI Coverage Status

Helpers to complement Go testing package.

Write tests with ease and fun!

This package is like testify/assert on steroids. :)

Features

  • Compelling output from failed tests:
    • Very easy-to-read dumps for expected and actual values.
    • Same text diff you loved in testify/assert.
    • Also visual diff in GoConvey web UI, if you use it (recommended).
  • Statistics with amount of passed/failed checks.
  • Colored output in terminal.
  • 100% compatible with testing package - check package just provide convenient wrappers for *testing.T methods and doesn't introduce new concepts like BDD, custom test suite or unusual execution flow.
  • All checks you may ever need! :)
  • Very easy to add your own check functions.
  • Concise, handy and consistent API, without dot-import!

Quickstart

Just 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"

Installation

Require Go 1.9.

go get github.com/powerman/check