How do you print in a Go test using the “testing” package?

后端 未结 6 1244
既然无缘
既然无缘 2020-12-12 12:07

I\'m running a test in Go with a statement to print something (i.e. for debugging of tests) but it\'s not printing anything.

func TestPrintSomething(t *testi         


        
6条回答
  •  无人及你
    2020-12-12 12:58

    For testing sometimes I do

    fmt.Fprintln(os.Stdout, "hello")
    

    Also, you can print to:

    fmt.Fprintln(os.Stderr, "hello)
    

提交回复
热议问题