testing.T.Log do not print out the log?

2,329 views
Skip to first unread message

Hill

unread,
Apr 14, 2012, 1:37:10 AM4/14/12
to golang-nuts
I have a little program to show this, why the "Test" is not showed on
the
console? But the fmt can do this. Did I miss something?

d:/Code/testinglog $ cat log_test.go
package main
import (
"testing"
"fmt"
)

func TestXxx(t *testing.T){
t.Log("Test")
fmt.Println("Test2")
}
d:/Code/testinglog $ go test
Test2
PASS
ok _/d_/Code/testinglog 0.276s

Dave Cheney

unread,
Apr 14, 2012, 1:46:59 AM4/14/12
to Hill, golang-nuts
go test -v

Is what you are looking for.

Cheers

Dave

Stephen Weinberg

unread,
Apr 14, 2012, 1:52:09 AM4/14/12
to golang-nuts
Why print a log if there was no error? It is just adding noise to what
should be "it worked".

If you don't agree, just run go test with the -v flag.

-- Stephen

Hill

unread,
Apr 14, 2012, 2:05:33 AM4/14/12
to golang-nuts
Thanks. This is what I want.
I found more info can be get from : go help testflag

Hill

unread,
Apr 14, 2012, 2:07:06 AM4/14/12
to golang-nuts
Thanks for the advice. I was just doing a rough test, to print out a
string.
Reply all
Reply to author
Forward
0 new messages