Releases: nalgeon/be
Releases · nalgeon/be
v0.3.0
Be is a minimal test assertions package. This release refines the failure messages produced by assertions. The API hasn't changed.
Failure messages produced by Equal:
// got: %#v; want: %#v
// got: %#v; want any of: %vFailure messages produced by Err:
// Got nil, want error:
// got: <nil>; want: error
// Got error, want nil:
// unexpected error: %v
// Error messages differ:
// got: %q; want: %q
// Error values differ:
// got: %T(%v); want: %T(%v)
// Error types differ:
// got: %T; want: %s
// All wants failed:
// got: %T(%v); want any of: %vFailure messages produced by True:
// got: false; want: truev0.2.0
Be is a minimal test assertions package. This release lets you check if a value matches any of the given values using be.Equal:
func Test(t *testing.T) {
t.Run("pass", func(t *testing.T) {
got := 2 * 3 * 7
be.Equal(t, got, 21, 42, 84)
// ok
})
t.Run("fail", func(t *testing.T) {
got := 2 * 3 * 7
be.Equal(t, got, 11, 12, 13)
// want any of the [11 12 13], got 42
})
}v0.1.0
Be is a minimal package for test assertions. If you feel like testify is too much, but is is too basic — you might like be.
Highlights:
- Minimal API:
Equal,Err, andTrueassertions. - Correctly compares
time.Timevalues and other types with anEqualmethod. - Flexible error assertions: check if an error exists, check its value, type, or any combination of these.
- Zero hassle.
Example usage:
func Test(t *testing.T) {
re, err := regexp.Compile("he??o")
be.Err(t, err, nil) // expects no error
be.True(t, strings.Contains(re.String(), "?"))
be.Equal(t, re.String(), "he??o")
}See the readme for details.