Skip to content

j-schwar/go-assert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-assert

go-assert is a simple package which implementes convienence testing assertions using go's built in testing package.

Installation

go get github.com/j-schwar/go-assert

Example

The default package name is assert.

Functions like assert.CondError and assert.FatalCondError are useful for table tests where you want to ensure that some cases are errors.

import (
	"github.com/j-schwar/go-assert"
	"testing"
)

func TestFoo(t *testing.T) {
	tests := []struct{
		name    string
		isError bool
		// ...
	}{
		// ...
	}
	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			_, err := Foo()
			// fail if unexpected error or if no error when expecting one
			assert.FatalCondError(t, test.isError, err)
		})
	}
}

About

Convenience Golang Testing Extensions

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages