-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Description
I have some helper functions that do certain tests and return helpful output as en
error. To preserve helpful line numbers I have to do this every time:
if e := test.Equals(obtained, expected); e != nil {
t.Fatal(e)
}
Something like this would be helpful:
t.Assert(test.Equals(obtained, expected))
Could look something like this:
func (c *common) Assert(err ...error) {
args := make([]error, 0, len(errs))
for _, e := range err {
if e != nil {
args = append(args, e)
}
}
if len(args) > 0 {
c.log(fmt.Sprintln(args...))
c.FailNow()
}
}
Or even this:
func (c *common) Assert(err error) {
if err != nil {
c.log(err.Error())
c.FailNow()
}
}Reactions are currently unavailable