Hide successful tests

738 views
Skip to first unread message

stephanos

unread,
Jun 3, 2013, 3:22:42 AM6/3/13
to golan...@googlegroups.com
Hi,

I'm just getting started with Go and wanted to make my test results easier to comprehend: How do I remove all successful/ignored tests from the test console output?

Regards
Stephan

Dave Cheney

unread,
Jun 3, 2013, 3:25:43 AM6/3/13
to stephanos, golang-nuts
What flags are you passing to go test ? _not_ passing -v will make the
test running be quiet unless there is a failure.

Cheers

Dave
> --
> 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...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

stephanos

unread,
Jun 3, 2013, 3:30:11 AM6/3/13
to golan...@googlegroups.com, stephanos
Hm, that's odd. I run my test with "go test ./..." (no -v) and it prints the result for every package with either "ok" or "?".

Volker Dobler

unread,
Jun 3, 2013, 3:31:23 AM6/3/13
to golan...@googlegroups.com
Am Montag, 3. Juni 2013 09:22:42 UTC+2 schrieb stephanos:
I'm just getting started with Go and wanted to make my test results easier to comprehend: How do I remove all successful/ignored tests from the test console output?

Don't use -v on go test ?

V. 
 

Volker Dobler

unread,
Jun 3, 2013, 3:32:36 AM6/3/13
to golan...@googlegroups.com, stephanos
Ah, you can't. This "ok" is not from tests it is "from package".

stephanos

unread,
Jun 3, 2013, 3:35:03 AM6/3/13
to golan...@googlegroups.com
Can't I use some Unix command to filter the results? I just don't know how exactly ... 

minux

unread,
Jun 3, 2013, 3:37:50 AM6/3/13
to stephanos, golan...@googlegroups.com
On Mon, Jun 3, 2013 at 3:35 PM, stephanos <stephan...@gmail.com> wrote:
Can't I use some Unix command to filter the results? I just don't know how exactly ... 
you can, of course.

the go tool prints per package status just as a progress indication, otherwise you
might wait a long time wondering what the computer is doing right now if you're
testing a lot of packages.

stephanos

unread,
Jun 3, 2013, 3:41:19 AM6/3/13
to golan...@googlegroups.com, stephanos
Well, could you enlighten me please? :)

My tests are rather fast, but I have quite a few packages and I don't want to scroll through them every time just to find the test failures (using a wide, not tall console).

Volker Dobler

unread,
Jun 3, 2013, 3:51:21 AM6/3/13
to golan...@googlegroups.com, stephanos
$ go test ./... | grep -E "^ok " -v

minux

unread,
Jun 3, 2013, 3:51:38 AM6/3/13
to stephanos, golan...@googlegroups.com
On Mon, Jun 3, 2013 at 3:41 PM, stephanos <stephan...@gmail.com> wrote:
Well, could you enlighten me please? :)
how about:
go test std | grep -Ev "^(\?|ok)\s+"

stephanos

unread,
Jun 3, 2013, 4:00:52 AM6/3/13
to golan...@googlegroups.com, stephanos
Thanks minux and Volker! :)

One more thing: can I run unit tests and e2e/functional tests separately?
Currently I run them all at once, but since my e2e tests are suffixed with "_e2e_test.go" it should be possible to run them separately...

But looking at the "go help test" documentation it seems I can only distinguish by [packages], not files.

Do you have an idea?

Volker Dobler

unread,
Jun 3, 2013, 5:02:45 AM6/3/13
to golan...@googlegroups.com, stephanos
Am Montag, 3. Juni 2013 10:00:52 UTC+2 schrieb stephanos:
But looking at the "go help test" documentation it seems I can only distinguish by [packages], not files.

Do you have an idea?

You can select packages and individual tests.
If all your e2e tests are named consistently, maybe
TestE2ESomeThing you can select those by
go test -run="E2E.*"

V. 

minux

unread,
Jun 3, 2013, 8:26:39 AM6/3/13
to stephanos, golan...@googlegroups.com
On Mon, Jun 3, 2013 at 4:00 PM, stephanos <stephan...@gmail.com> wrote:
One more thing: can I run unit tests and e2e/functional tests separately?
Currently I run them all at once, but since my e2e tests are suffixed with "_e2e_test.go" it should be possible to run them separately...

But looking at the "go help test" documentation it seems I can only distinguish by [packages], not files.

Do you have an idea?
Build tags still apply to test files, so you can do this:

This is file1_test.go:
// +build !Disable1

package test

import "testing"

func Test1(t *testing.T) {}

This is file2_test.go
// +build !Disable2

package test

import "testing"

func Test2(t *testing.T) {}


then you can do this (assume pkg is the import path of the above test package)
go test pkg  # run all tests
go test -tags Disable1 pkg # only run Test2
go test -tags Disable2 pkg # only run Test1
go test -tags "Disable1 Disable2" pkg # go tool will show error because you excluded every test file

Reply all
Reply to author
Forward
0 new messages