{"action":"created","issue":{"url":"https://api.github.com/repos/onsi/gomega/issues/255","repository_url":"https://api.github.com/repos/onsi/gomega","labels_url":"https://api.github.com/repos/onsi/gomega/issues/255/labels{/name}","comments_url":"https://api.github.com/repos/onsi/gomega/issues/255/comments","events_url":"https://api.github.com/repos/onsi/gomega/issues/255/events","html_url":"https://github.com/onsi/gomega/issues/255","id":282108235,"number":255,"title":"Better output when using with go  XUnit-style tests","user":{"login":"smyrman","id":75205,"avatar_url":"https://avatars2.githubusercontent.com/u/75205?v=4","gravatar_id":"","url":"https://api.github.com/users/smyrman","html_url":"https://github.com/smyrman","followers_url":"https://api.github.com/users/smyrman/followers","following_url":"https://api.github.com/users/smyrman/following{/other_user}","gists_url":"https://api.github.com/users/smyrman/gists{/gist_id}","starred_url":"https://api.github.com/users/smyrman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smyrman/subscriptions","organizations_url":"https://api.github.com/users/smyrman/orgs","repos_url":"https://api.github.com/users/smyrman/repos","events_url":"https://api.github.com/users/smyrman/events{/privacy}","received_events_url":"https://api.github.com/users/smyrman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-12-14T13:54:16Z","updated_at":"2018-02-09T03:20:58Z","closed_at":null,"author_association":"NONE","body":"It would be nice if the gomega matcher output could be more short / useful for XUnit tests in terms of printing the correct file/line numbers for the error, and nothing more.\r\n\r\nMy use-case is to use Gomega with a non-Ginko BDD-style framework called [spec](https://github.com/sclevine/spec), which rely on the built-in Go 7+ sub-tests for execution.\r\n\r\nE.g. with the following example code (one test using Gomega, another one not using Gomega):\r\n```go\r\npackage main_test\r\n\r\nimport (\r\n\t\"testing\"\r\n\r\n\t\"github.com/onsi/gomega\"\r\n\t\"github.com/sclevine/spec\"\r\n)\r\n\r\nfunc TestExample(t *testing.T) {\r\n\tspec.Run(t, \"Example\", func(t *testing.T, when spec.G, it spec.S) {\r\n\t\tvar result *struct{ i int }\r\n\r\n\t\tit(\"should not be nil\", func() {\r\n\t\t\tif result == nil {\r\n\t\t\t\tt.Error(\"result is nil\")\r\n\t\t\t}\r\n\t\t})\r\n\t})\r\n}\r\n\r\nfunc TestExampleGomega(t *testing.T) {\r\n\tspec.Run(t, \"Example\", func(t *testing.T, when spec.G, it spec.S) {\r\n\t\tvar result *struct{ i int }\r\n\t\tgomega.RegisterTestingT(t)\r\n\t\tit(\"should not be nil\", func() {\r\n\t\t\tgomega.Expect(result).ToNot(gomega.BeNil())\r\n\t\t})\r\n\t})\r\n}\r\n```\r\n\r\nI wold expect similar output from both tests. e.g.:\r\n```\r\n% go test -v\r\n=== RUN   TestExample\r\n=== RUN   TestExample/Example\r\n=== RUN   TestExample/Example/should_not_be_nil\r\n--- FAIL: TestExample (0.00s)\r\n    --- FAIL: TestExample/Example (0.00s)\r\n        --- FAIL: TestExample/Example/should_not_be_nil (0.00s)\r\n        \tmy_test.go:16: result is nil\r\n=== RUN   TestExampleGomega\r\n=== RUN   TestExampleGomega/Example\r\n=== RUN   TestExampleGomega/Example/should_not_be_nil\r\n--- FAIL: TestExampleGomega (0.00s)\r\n    --- FAIL: TestExampleGomega/Example (0.00s)\r\n        --- FAIL: TestExampleGomega/Example/should_not_be_nil (0.00s)\r\n        \tmy_test.go:16:\r\n        \t\tExpected\r\n        \t\t    <*struct { i int } | 0x0>: nil\r\n        \t\tnot to be nil\r\nFAIL\r\nexit status 1\r\nFAIL\tgithub.com/searis/play/gomegaoutput\t0.008s\r\n```\r\n\r\nInstead I get the filename / line number of a file internal to Gomega, and a trace-back that adds little value for my test:\r\n```\r\n% go test -v\r\n=== RUN   TestExample\r\n=== RUN   TestExample/Example\r\n=== RUN   TestExample/Example/should_not_be_nil\r\n--- FAIL: TestExample (0.00s)\r\n    --- FAIL: TestExample/Example (0.00s)\r\n        --- FAIL: TestExample/Example/should_not_be_nil (0.00s)\r\n        \tmy_test.go:16: result is nil\r\n=== RUN   TestExampleGomega\r\n=== RUN   TestExampleGomega/Example\r\n=== RUN   TestExampleGomega/Example/should_not_be_nil\r\n--- FAIL: TestExampleGomega (0.00s)\r\n    --- FAIL: TestExampleGomega/Example (0.00s)\r\n        --- FAIL: TestExampleGomega/Example/should_not_be_nil (0.00s)\r\n        \ttesting_t_support.go:22: \r\n        \t\t\t/Users/smyrman/.local/src/github.com/searis/play/gomegaoutput/vendor/github.com/onsi/gomega/internal/assertion/assertion.go:69 +0x1ef\r\n        \t\tgithub.com/searis/play/gomegaoutput/vendor/github.com/onsi/gomega/internal/assertion.(*Assertion).ToNot(0xc42004eac0, 0x124fa40, 0x1321830, 0x0, 0x0, 0x0, 0xc42004eac0)\r\n        \t\t\t/Users/smyrman/.local/src/github.com/searis/play/gomegaoutput/vendor/github.com/onsi/gomega/internal/assertion/assertion.go:39 +0xae\r\n        \t\tgithub.com/searis/play/gomegaoutput_test.TestExampleGomega.func1.1()\r\n        \t\t\t/Users/smyrman/.local/src/github.com/searis/play/gomegaoutput/my_test.go:27 +0xbe\r\n        \t\tgithub.com/searis/play/gomegaoutput/vendor/github.com/sclevine/spec.run(0xc420042ec8, 0x1, 0x1)\r\n        \t\t\t/Users/smyrman/.local/src/github.com/searis/play/gomegaoutput/vendor/github.com/sclevine/spec/spec.go:182 +0x37\r\n        \t\tgithub.com/searis/play/gomegaoutput/vendor/github.com/sclevine/spec.Run.func3(0xc4200f85a0, 0xc420044760, 0x1, 0x1, 0xc4200124e8, 0x1, 0x1, 0x5a328010, 0x1, 0x1, ...)\r\n        \t\t\t/Users/smyrman/.local/src/github.com/searis/play/gomegaoutput/vendor/github.com/sclevine/spec/spec.go:176 +0x3af\r\n        \t\tgithub.com/searis/play/gomegaoutput/vendor/github.com/sclevine/spec.node.run.func1(0xc4200f85a0)\r\n        \t\t\t/Users/smyrman/.local/src/github.com/searis/play/gomegaoutput/vendor/github.com/sclevine/spec/parser.go:132 +0x54\r\n        \t\ttesting.tRunner(0xc4200f85a0, 0xc42000a5a0)\r\n        \t\t\t/usr/local/Cellar/go/1.9.1/libexec/src/testing/testing.go:746 +0xd0\r\n        \t\tcreated by testing.(*T).Run\r\n        \t\t\t/usr/local/Cellar/go/1.9.1/libexec/src/testing/testing.go:789 +0x2de\r\n        \t\t\r\n        \t\tExpected\r\n        \t\t    <*struct { i int } | 0x0>: nil\r\n        \t\tnot to be nil\r\nFAIL\r\nexit status 1\r\nFAIL\tgithub.com/searis/play/gomegaoutput\t0.008s\r\n```\r\n\r\n\r\nPS! The following recent addition to the Go testing library may be of some use in prettifying this:\r\n- https://golang.org/pkg/testing/#T.Helper"},"comment":{"url":"https://api.github.com/repos/onsi/gomega/issues/comments/364323855","html_url":"https://github.com/onsi/gomega/issues/255#issuecomment-364323855","issue_url":"https://api.github.com/repos/onsi/gomega/issues/255","id":364323855,"user":{"login":"onsi","id":558230,"avatar_url":"https://avatars2.githubusercontent.com/u/558230?v=4","gravatar_id":"","url":"https://api.github.com/users/onsi","html_url":"https://github.com/onsi","followers_url":"https://api.github.com/users/onsi/followers","following_url":"https://api.github.com/users/onsi/following{/other_user}","gists_url":"https://api.github.com/users/onsi/gists{/gist_id}","starred_url":"https://api.github.com/users/onsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onsi/subscriptions","organizations_url":"https://api.github.com/users/onsi/orgs","repos_url":"https://api.github.com/users/onsi/repos","events_url":"https://api.github.com/users/onsi/events{/privacy}","received_events_url":"https://api.github.com/users/onsi/received_events","type":"User","site_admin":false},"created_at":"2018-02-09T03:20:58Z","updated_at":"2018-02-09T03:20:58Z","author_association":"OWNER","body":"thanks - note you'll have to be on Go 1.9 - it's probably a terrible experience on older versions of Go.  I can try to fix that.."}}
{"actor":{"display_login":"onsi"}}