🥘 Assertions for Go's testing package.
Switch branches/tags
Nothing to show
Clone or download
Latest commit 7c8c113 Aug 27, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmd Remove metalinter Apr 14, 2018
is Fix error message Apr 14, 2018
go.mod Add go.mod Aug 27, 2018
license.txt Init. Aug 25, 2017
readme.md Update readme.md Jul 12, 2018
wat.go Refactor. Aug 28, 2017
wat_test.go Refactor. Aug 28, 2017



Assertions for Go's testing package.

  • Assertions call t.Fatal() on failure.
  • Assertions use t.Helper() for traces.
  • Assertions take optional output messages.
  • No external dependencies.


$ go get -u github.com/olav/wat/...

This package requires Go 1.9+.


package example

import (


func TestExample(t *testing.T) {
	is.Equal(t, 5, 2+3)
	is.Element(t, []int{1, 2, 3}, 3)
	is.Error(t, errors.New("example"))
	is.Substring(t, "example", "ample")

See below for a complete list of assertions.

You can also use the package outside of testing. If you pass nil instead of *testing.T, the funcs return strings instead of exiting. Successful funcs return "", while failed funcs return error messages.

Package is


// Equal asserts that two values are equal.
func Equal(t *testing.T, value1, value2 interface{}, messages ...interface{}) {}

// NotEqual asserts that two values are not equal.
func NotEqual(t *testing.T, value1, value2 interface{}, messages ...interface{}) {}


// Nil asserts that a value is, uh, you know, nil.
func Nil(t *testing.T, value interface{}, messages ...interface{}) {} 

// NotNil asserts that a value is non-nil.
func NotNil(t *testing.T, value interface{}, messages ...interface{}) {}

// Zero asserts that a value is its type's zero-value.
func Zero(t *testing.T, value interface{}, messages ...interface{}) {}

// NotZero asserts that a value does not equal its type's zero-value.
func NotZero(t *testing.T, value interface{}, messages ...interface{}) {}

// Error asserts that a value is a non-nil, non-empty error.
func Error(t *testing.T, value interface{}, messages ...interface{}) {}


// Bool asserts that a value is a bool.
func Bool(t *testing.T, value interface{}, messages ...interface{}) {}

// True asserts that a value is true.
func True(t *testing.T, value bool, messages ...interface{}) {} 

// False asserts that a value is false.
func False(t *testing.T, value bool, messages ...interface{}) {}


// Int asserts that a value is an int.
func Int(t *testing.T, value interface{}, messages ...interface{}) {}

// Above asserts that an int is above an expected value.
func Above(t *testing.T, expected, actual int, messages ...interface{}) {}

// Below asserts that an int is below an expected value.
func Below(t *testing.T, expected, actual int, messages ...interface{}) {}

// Delta asserts that two ints are within a delta.
func Delta(t *testing.T, value1, value2, delta int, messages ...interface{})


// String asserts that a value is a string.
func String(t *testing.T, value interface{}, messages ...interface{}) {}

// Substring asserts that a string contains a substring.
func Substring(t *testing.T, value, substring string, messages ...interface{}) {}

// NotSubstring asserts that a string does not contain a substring.
func NotSubstring(t *testing.T, value, substring string, messages ...interface{}) {}


// Slice asserts that a value is a slice.
func Slice(t *testing.T, value interface{}, messages ...interface{}) {}

// Element asserts that a slice contains an element.
func Element(t *testing.T, value, element interface{}, messages ...interface{}) {}

// NotElement asserts that a slice does not contain an element.
func NotElement(t *testing.T, value, element interface{}, messages ...interface{}) {}


// Timeframe asserts that two time instants are within a delta.
func Timeframe(t *testing.T, value1, value2 time.Time, delta time.Duration, messages ...interface{}) {}


Unstable. Anything may change. There's no backwards compatability.

Your best bet is to vendor the repo or just copy the bits you need.


Original code in this repo is licensed under the Apache License 2.0.