Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 861 Bytes

README.md

File metadata and controls

31 lines (22 loc) · 861 Bytes

AssertG - Fluent Assertions for Go

CI

Go package to provide an intuitive set of strongly typed assertions for use in unit testing.

Inspiration and Goals

AssertG takes inspiration from AssertJ (an assertion library for Java) and Testify (a toolkit with common assertions for Go).

The assert package

Example:

import (
  "testing"
  "github.com/skhome/assertg/assert"
)

func TestSomething(t *testing.T) {
  assert.ThatString(t, "foobar").
    IsNotEmpty().
    StartsWith("foo").
    EndsWith("bar")

  assert.ThatSlice(t, []int{2, 4, 6}).
    HasSize(3).
    HasAllMatch(func(num int) bool { return num % 2 == 0 })
}