Skip to content

allisson/go-assert

Repository files navigation

go-assert

Build Status Go Report Card go.dev reference

Simple asserts to use with golang testing.

Quickstart

// file test_test.go
package test

import (
    "testing"

    assert "github.com/allisson/go-assert"
)

func TestExamples(t *testing.T) {
    assert.Equal(t, 1, 1)
    assert.NotEqual(t, 1, 2)
    assert.Nil(t, nil)
    assert.NotNil(t, 1)
}
go test -v
=== RUN   TestExamples
--- PASS: TestExamples (0.00s)
PASS
// file test_test.go
package test

import (
    "testing"

    assert "github.com/allisson/go-assert"
)

func TestExamples(t *testing.T) {
    assert.Equal(t, 1, 2)
}
go test -v
=== RUN   TestExamples
--- FAIL: TestExamples (0.00s)
    test_test.go:10: assertion_type=Equal, expected_value=1, expected_type=int, current_value=2, current_type=int
FAIL
exit status 1