RSpec 2 & 3 results that Jenkins can read. Probably a few other CI services, too.
Inspired by the work of Diego Souza on RSpec Formatters after frustration with CI Reporter.
Install the gem:
gem install rspec_junit_formatterUse it:
rspec --format RspecJunitFormatter --out rspec.xmlYou'll get an XML file rspec.xml with your results in it.
You can use it in combination with other formatters, too:
rspec --format progress --format RspecJunitFormatter --out rspec.xmlAdd it to your Gemfile if you're using Bundler. Put it in the same groups as rspec.
group :test do
gem "rspec"
gem "rspec_junit_formatter"
endPut the same arguments as the commands above in your .rspec:
--format RspecJunitFormatter
--out rspec.xmlFor use with parallel_tests, add $TEST_ENV_NUMBER in the output file option (in .rspec or .rspec_parallel) to avoid concurrent process write conflicts.
--format RspecJunitFormatter
--out tmp/rspec<%= ENV["TEST_ENV_NUMBER"] %>.xmlThe formatter includes $TEST_ENV_NUMBER in the test suite name within the XML, too.
- XML can only represent a limited subset of characters which excludes null bytes and most control characters. This gem will use character entities where possible and fall back to replacing invalid characters with Ruby-like escape codes otherwise. For example, the null byte becomes
\0.
- It would be nice to split things up into individual test suites, although would this correspond to example groups? The subject? The spec file? Not sure yet.
Run the specs with bundle exec rake spec. Run the specs against a matrix of rspec versions using bundle exec rake spec:all.
Bump the gem version in the gemspec, and commit. Then bundle exec rake build to build a gem package, bundle exec rake install to install and test it locally, then bundle exec rake release to tag and push the commits and gem.
The MIT License, see LICENSE.