/assert

Simple assertions for Go (golang) tests

Primary LanguageGoApache License 2.0Apache-2.0

assert

Build Status GoDoc Go Report Card

assert is Go package that provides convenience methods for writing assertions in standard Go tests.

You can write this test with assert:

func TestSomething(t *testing.T) {
  i, err := doSomething()
  assert.NoErr(t, err)
  assert.Equal(t, i, 123, "returned integer")
}

Instead of writing this test with only the standard testing library:

func TestSomething(t *testing.T) {
  i, err := doSomething()
  if err != nil {
    t.Fatalf("error encountered: %s", err)
  }
  if i != 123 {
    t.Fatalf("returned integer was %d, not %d", i, 123)
  }
}