bitbucket.org/ronoaldo/assert
assert
– import “ronoaldo.gopkg.net/assert”
Package assert contains a simple set of assertions to help writing unit tests.
The main pourpose of this package is to explicity tell when a test expectation wasn’t filled, making easy to developers used to write Junit tests to write up tests in Go.
Warning: This API is still in beta and is subject to change.
Usage
type A
type A struct {
*testing.T
}
A is a wrapper for testing.T that adds some shortcuts enabling test assertions for common conditions.
func (*A) Equals
func (assert *A) Equals(a, b interface{}, message string, p ...interface{})
Equals asserts that the values ‘a’ and ‘b’ are equal using reflect.DeepEqual.
func (*A) ErrorIsNil
func (assert *A) ErrorIsNil(err error)
ErrorIsNil asserts that the specified error is nil, otherwise fails the test.
func (*A) False
func (assert *A) False(expr bool, message string, p ...interface{})
False asserts that the expression ‘e’ is false, raising t.Fatal otherwise, with the specified message m.
func (*A) FileExists
func (assert *A) FileExists(path string)
FileExists assert that the speficied file path exists, raising t.Fatal otherwise, with the specified message m.
func (*A) IsNil
func (assert *A) IsNil(value interface{}, message string, p ...interface{})
IsNil asserts that the parameter ‘value’ is nil, raising t.Fatal otherwise, with the specified message.
func (*A) IsNotNil
func (assert *A) IsNotNil(value interface{}, message string, p ...interface{})
IsNotNil asserts that the value v is not nil, raising t.Fatal otherwise, with the specified message m.
func (*A) True
func (assert *A) True(expr bool, message string, p ...interface{})
True asserts that the expression is true, failing the test otherwise. Logs the call trace and the message to the test output.