Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhanced Go test output (quiet by default, print package path) #511

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pohly
Copy link
Contributor

@pohly pohly commented Jul 25, 2018

"ginkgo" can replace "go test" as test runner also for normal Go
tests, but the output was different:

  • tests were always run with -test.v and thus produced output
    also on success
  • there was no indication of which test produced the output

Now the output behavior is closer to that of "go test":

  • tests run in verbose mode only when "ginkgo -v" is used
  • after each test, a line with "ok/FAIL " is
    printed

That line is not quite the same as in "go test", which prints the
import path, but close enough. That line is important when running in
quite mode, because without it one would not be able to tell what
tests were run. Even in verbose mode the output could be
ambiguous (for example, when different packages happen to contain the
same test).

Example:

$ go test ./pkg/log ./pkg/log/testlog
ok github.com/foo/bar/pkg/log 0.005s
--- FAIL: TestOutput2 (0.00s)
testlog_test.go:40: INFO TestOutput2
testlog_test.go:42: was asked to fail
FAIL
FAIL github.com/foo/bar/pkg/log/testlog 1.417s

$ ginkgo ./pkg/log ./pkg/log/testlog
PASS
ok ./pkg/log
--- FAIL: TestOutput2 (0.00s)
testlog_test.go:40: INFO TestOutput2
testlog_test.go:42: was asked to fail
FAIL
FAIL ./pkg/log/testlog

Ginkgo ran 2 suites in 2.145256459s
Test Suite Failed

Fixes: #508

"ginkgo" can replace "go test" as test runner also for normal Go
tests, but the output was different:
- tests were always run with -test.v and thus produced output
  also on success
- there was no indication of which test produced the output

Now the output behavior is closer to that of "go test":
- tests run in verbose mode only when "ginkgo -v" is used
- after each test, a line with "ok/FAIL <test path>" is
  printed

That line is not quite the same as in "go test", which prints the
import path, but close enough. That line is important when running in
quite mode, because without it one would not be able to tell what
tests were run. Even in verbose mode the output could be
ambiguous (for example, when different packages happen to contain the
same test).

Example:

$ go test ./pkg/log ./pkg/log/testlog
ok  	github.com/foo/bar/pkg/log	0.005s
--- FAIL: TestOutput2 (0.00s)
	testlog_test.go:40: INFO TestOutput2
	testlog_test.go:42: was asked to fail
FAIL
FAIL	github.com/foo/bar/pkg/log/testlog	1.417s

$ ginkgo ./pkg/log ./pkg/log/testlog
PASS
ok ./pkg/log
--- FAIL: TestOutput2 (0.00s)
	testlog_test.go:40: INFO TestOutput2
	testlog_test.go:42: was asked to fail
FAIL
FAIL ./pkg/log/testlog

Ginkgo ran 2 suites in 2.145256459s
Test Suite Failed

Fixes: onsi#508
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make passing of -test.v configurable
1 participant