Skip to content

Commit

Permalink
Document stream capture and reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
sj26 committed May 26, 2018
1 parent 4d582a6 commit 49195d8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Expand Up @@ -58,6 +58,30 @@ For use with `parallel_tests`, add `$TEST_ENV_NUMBER` in the output file option

The formatter includes `$TEST_ENV_NUMBER` in the test suite name within the XML, too.

### Capturing output

If you like, you can capture the standard output and error streams of each test into the `:stdout` and `:stderr` example metadata which will be added to the junit report, e.g.:

```ruby
# spec_helper.rb

RSpec.configure do |config|
# register around filter that captures stdout and stderr
config.around(:each) do |example|
$stdout = StringIO.new
$stderr = StringIO.new

example.run

example.metadata[:stdout] = $stdout.string
example.metadata[:stderr] = $stderr.string

$stdout = STDOUT
$stderr = STDERR
end
end
```

## Caveats

* XML can only represent a [limited subset of characters][xml-charsets] which
Expand Down

0 comments on commit 49195d8

Please sign in to comment.