I filed https://github.com/golang/go/issues/21627. Thanks for the heads up.
On Fri, Aug 25, 2017 at 1:39 PM, Caleb Spare <cesp...@gmail.com> wrote: > Oh, shoot. It should be part of the interface. That was part of the > proposal: > > https://github.com/golang/proposal/blob/master/design/ > 4899-testing-helper.md > > but I forgot to add it. > > On Fri, Aug 25, 2017 at 1:16 PM, lukas.malkmus via golang-nuts < > golang-nuts@googlegroups.com> wrote: > >> I'm using helper functions in my test, for example this one: >> >> // assert fails the test if the condition is false. >> func assert(tb testing.TB, condition bool, msg string, v ...interface{}) >> { >> if !condition { >> _, file, line, _ := runtime.Caller(1) >> fmt.Printf("\033[31m%s:%d: "+msg+"\033[39m\n\n", append([]interface{}{ >> filepath.Base(file), line}, v...)...) >> tb.FailNow() >> } >> } >> >> I hoped that I could improve these helpers with the new (*B).Helper() and >> (*T).Helper() methods: >> >> // assert fails the test if the condition is false. >> func assert(tb testing.TB, condition bool, msg string, v ...interface{}) { >> tb.Helper() >> if !condition { >> tb.Fatalf("\033[31m "+msg+"\033[39m\n\n", v...) >> } >> } >> >> I expected Go to print the file and line number of the failing test, >> followed by a red message. Instead, the file and line number is of form " >> <autogenerated>:1:" >> >> It works if I replace tb testing.TB with t testing.T. Is there a reason >> the new Helper() method is part of the TB interface but not working as >> expected? Or could it be a bug? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.