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.