Skip to content

Releases: nalgeon/be

v0.3.0

24 Aug 09:34

Choose a tag to compare

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: %v

Failure 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: %v

Failure messages produced by True:

// got: false; want: true

v0.2.0

12 Jul 05:38

Choose a tag to compare

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

07 Jul 17:13

Choose a tag to compare

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, and True assertions.
  • Correctly compares time.Time values and other types with an Equal method.
  • 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.