testify/assert/doc.go
2012-10-17 17:31:15 +01:00

64 lines
1.8 KiB
Go

// A set of comprehensive testing tools for use with the normal Go testing system.
//
// Example Usage
//
// The following is a complete example using assert in a standard test function:
// import (
// "testing"
// "assert"
// )
//
// func TestSomething(t *testing.T) {
//
// var a string = "Hello"
// var b string = "Hello"
//
// assert.Equal(t, a, b, "The two words should be the same.")
//
// }
//
// Assertions
//
// Assertions allow you to easily write test code, and are global funcs in the `assert` package.
// All assertion functions take, as the first argument, the `*testing.T` object provided by the
// testing framework. This allows the assertion funcs to write the failings and other details to
// the correct place.
//
// Every assertion function also takes an optional string message as the final argument,
// allowing custom error messages to be appended to the message the assertion method outputs.
//
// Here is an overview of the assert functions:
//
// assert.Equal(t, expected, actual [, message])
//
// assert.NotEqual(t, notExpected, actual [, message])
//
// assert.True(t, actualBool [, message])
//
// assert.False(t, actualBool [, message])
//
// assert.Nil(t, actualObject [, message])
//
// assert.NotNil(t, actualObject [, message])
//
// assert.Implements(t, (*MyInterface)(nil), new(MyObject) [,message])
//
// assert.IsType(t, expectedObject, actualObject [, message])
//
// assert.Contains(t, string, substring [, message])
//
// assert.NotContains(t, string, substring [, message])
//
// assert.Panics(t, func(){
//
// // call code that should panic
//
// } [, message])
//
// assert.NotPanics(t, func(){
//
// // call code that should not panic
//
// } [, message])
package assert