Skip to content

Commit

Permalink
testjson: improve example in overview.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnephin committed Oct 9, 2020
1 parent 3c420fb commit 493610c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions testjson/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ Events are passed to a formatter for output.
Example
This example reads the test2json output from os.Stdin. It builds an
Execution from the output, then it prints the number of tests run.
This example reads the test2json output from os.Stdin. It sends every
event to the handler, builds an Execution from the output, then it
prints the number of tests run.
exec, err := testjson.ScanTestOutput(testjson.ScanConfig{Stdout: os.Stdin})
exec, err := testjson.ScanTestOutput(testjson.ScanConfig{
// Stdout is a reader that provides the test2json output stream.
Stdout: os.Stdin,
// Handler receives TestEvents and error lines.
Handler: eventHandler,
})
if err != nil {
return fmt.Errorf("failed to scan testjson: %v", err)
return fmt.Errorf("failed to scan testjson: %w", err)
}
fmt.Println("Ran %d tests", exec.Total())
Expand Down

0 comments on commit 493610c

Please sign in to comment.