-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Testing: non-error output #129201
Comments
vscode/src/vs/vscode.proposed.d.ts Lines 1793 to 1803 in 9430366
Tomorrow I'll polish things a bit and have clicking on the output open the test output and select the line in a terminal. |
To clarify, calling |
That's correct @firelizzard18 |
I'm trying to think of how best to use func TestFoo(t *testing.T) {
// produces output
t.Log("Hello world")
// causes the test to fail
t.Fail()
} This is what I have to work with: {"Time":"2021-08-11T18:40:31.483381884-05:00","Action":"run","Package":"foo","Test":"TestFoo"}
{"Time":"2021-08-11T18:40:31.483455845-05:00","Action":"output","Package":"foo","Test":"TestFoo","Output":"=== RUN TestFoo\n"}
{"Time":"2021-08-11T18:40:31.483460908-05:00","Action":"output","Package":"foo","Test":"TestFoo","Output":" foo_test.go:9: Hello world\n"}
{"Time":"2021-08-11T18:40:31.483465236-05:00","Action":"output","Package":"foo","Test":"TestFoo","Output":"--- FAIL: TestFoo (0.00s)\n"}
{"Time":"2021-08-11T18:40:31.483467643-05:00","Action":"fail","Package":"foo","Test":"TestFoo","Elapsed":0}
{"Time":"2021-08-11T18:40:31.483471215-05:00","Action":"output","Package":"foo","Output":"FAIL\n"}
{"Time":"2021-08-11T18:40:31.483559559-05:00","Action":"output","Package":"foo","Output":"FAIL\tfoo\t0.001s\n"}
{"Time":"2021-08-11T18:40:31.483597857-05:00","Action":"fail","Package":"foo","Elapsed":0.001}
Please note, the failure event does not give a reason for failure. The underlying Go test infrastructure does not make any association between a test failing and a reason why it failed. There are various methods that produce output and fail the test, such as In order to preserve the one-to-one correspondence between the test output terminal and directly running
Adding a severity parameter or
I'd like the extension to recognize this pattern and create a corresponding Do you see any better solutions? |
I think approach (1) is the recommended way here. I view the new functionality not as an alternative way to append messages to a certain test, but rather a way to annotate test runners' standard output--which should usually be streamed in anyway--with metadata about how it was generated. This is in contrast to the failure TestMessage which is rich, well-structured diagnostic information that the user can dig into. |
Verifier: scan through the API and make sure docs make sense. There were no functional changes in this issue since last verification. |
/verified Docs look good to me. |
@connor4312 how do I turn in this feature? |
I discussed this with @connor4312 on #122208 (comment), but now I have a concrete need.
Go has benchmarks. Benchmarks (in Go) are defined and run in much the same way that tests are. Tests are defined with
func TestXxx(*testing.T)
and benchmarks are defined withfunc BenchmarkXxx(*testing.B)
; tests are run withgo test -run='^TestXxx$'
and benchmarks are run withgo test -bench='^BenchmarkXxx$'
. So it is natural for benchmarks to be exposed along side tests in the testing API.Given a benchmark:
Running this benchmark will produce something like the following:
For running benchmarks with the testing API to be meaningful, the user needs to see the results of the benchmark (the second BenchmarkFoo line). Previously, I could attach an info message to a test that passed. That capability was removed in the finalized testing API.
The text was updated successfully, but these errors were encountered: