In other test frameworks that I have used, when writing test helpers, it's nice to be able to automatically test them, i.e. test that they fail as well as pass.
Let me use the following for the helper (in reality it's a lot more complex):
func IsRedirect(t *testing.T, code int) {
assert.True(t, code >= 300)
assert.True(t, code < 400)
}
Then sure, I can write:
func TestIsRedirect(t *testing.T) {
IsRedirect(t, http.StatusSeeOther)
}
But I'd also like to write something like:
func TestNotRedirect(t *testing.T) {
t.RequireFailure()
IsRedirect(t, http.StatusOK)
}
Note, I don't really want to write:
func IsRedirect(code int) bool
because the function has more than just one or two conditions that can fail, and I want to be able to assert
on the specific failure case.