Btw, I have to make a correction to my previous post (see below). This init() doesn't seem to take effect all the time (or at all in some projects). I also tried putting them into TestMain instead inside of my test files with the same "doesn't always work" result (most of the time, it does not detect the level). Must be a combination of t.Parallel() and not calling glog.Flush().
The only that truly works 100% of the time is to insert it into each test method. But that's pretty ugly though. I am not sure when Golang Tests introduced the -args flag; but, today I was reading the docs again and noticed this new -args flag. It works! $ go test -v -args -v 3 -logtostderr true Target a specific function: $ go test -cover -v -run TestEventsTableTests -args -v 3 -logtostderr true Obviously, -cover and -v are optional for tests and you can just get away with: $ go test -run TestEventsTableTests -args -v 3 ^- glog seems to output to stderr anyways, without specifying -logtostderr. Per the docs, you have to add it to the end of the packages to test if specifying packages: $ go test -cover -v ./podcast -args -v 3 -logtostderr true On Thursday, May 12, 2016 at 2:03:40 PM UTC-4, edunc...@gmail.com wrote: > > This is what I use with glog in my test file(s): > > func init() { > if testing.Verbose() { > flag.Set("alsologtostderr", "true") > flag.Set("v", "5") > } > } > > (I just ran into this today, fyi) > -- 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.