• Stars
    star
    294
  • Rank 141,303 (Top 3 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 13 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

RSpec results that your CI can read

RSpec JUnit Formatter

Build results Gem version

RSpec 2 & 3 results that your CI can read. Jenkins, Buildkite, CircleCI, Gitlab, and probably more, too.

Usage

Install the gem:

gem install rspec_junit_formatter

Use it:

rspec --format RspecJunitFormatter --out rspec.xml

You'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.xml

Using in your project with Bundler

Add 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", require: false
end

Put the same arguments as the commands above in your .rspec:

--format RspecJunitFormatter
--out rspec.xml

Parallel tests

For 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"] %>.xml

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.:

# 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

Note that this example captures all output from every example all the time, potentially interfering with local debugging. You might like to restrict this to only on CI, or by using rspec filters.

Caveats

  • 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.

Development

Run the specs with bundle exec rake, which uses Appraisal to run the specs against all supported versions of rspec.

Releasing

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.

License

The MIT License, see LICENSE.

Thanks

Inspired by the work of Diego Souza on RSpec Formatters after frustration with CI Reporter.

More Repositories

1

mailcatcher

Catches mail and serves it through a dream.
Ruby
6,036
star
2

sidekiq-cloudwatchmetrics

Publish Sidekiq metrics to AWS CloudWatch
Ruby
50
star
3

skinny

Thin WebSocketsβ€”they'll fit
Ruby
45
star
4

puma-plugin-systemd

Puma integration with systemd for better daemonising under modern Linux systemds: notify, status, watchdog
Ruby
38
star
5

awscli-keyring

AWS CLI Keyring
Python
26
star
6

zipstream

Create zip files to a stream with rails integration.
Ruby
21
star
7

home

My castle.
Shell
17
star
8

git-buildkite

Start Buildkite builds using git with a clickable link
Shell
15
star
9

soundwave

An example Ruby on Rails app with seekable waveform of audio attachment.
Ruby
14
star
10

node-mdns

Extensible mDNS in node.js using ndns
JavaScript
13
star
11

packer-post-processor-tfvars

Packer post-processor exporting terraform variables
Go
11
star
12

rails-subdomain

Some convenience methods making subdomains in Rails a whole lot easier.
Ruby
11
star
13

dotjs-fluid

Userscript to put dotjs into your Fluid browsers
JavaScript
10
star
14

virtus-multiparams

Rails multiparams support for virtus models
Ruby
8
star
15

rbenv-install

A really thin wrapper around ruby-build for rbenv.
Shell
7
star
16

git-worktree-buildkite-hooks

Buildkite hooks to use Git worktrees
Shell
7
star
17

jquery.scrollmarkers

jQuery scrollmarkers--decorate the scrollbar with jump markers
JavaScript
7
star
18

ruby-1.9.3-p0

A clone of ruby-1.9.3-p0 for patching
C
7
star
19

derail

My curated set of technology choices.
Ruby
6
star
20

rubygems-keychain

Store Rubygems api keys and signing certificates securely in your macOS Keychain
Ruby
6
star
21

rack-s3

A Rack::Static like middleware for serving assets from S3
Ruby
6
star
22

christen

Run Rails, DNS and sign SSL all together like DNSimple.
Ruby
6
star
23

sinatra-diet

Sinatra on a Diet gets Thin and Skinny, asynchronously
Ruby
5
star
24

gem

Just enough not-Rubygems to index a collection of gems for download.
Ruby
4
star
25

rack-process

Proxy to a rack application in a separate process
Ruby
4
star
26

rspec-rails-assign

A nicer way to asset instance variable assignments in controller examples
Ruby
4
star
27

happening

An easy way to do event-based and scheduled programming in Ruby based on libevent.
Ruby
3
star
28

syllable

Made to partially satisfy a bountify bounty
Ruby
3
star
29

github-pipeline-upload-buildkite-plugin

Python
2
star
30

gravatard

A simple gravatar.com drop-in made for Railscamp 8
Ruby
2
star
31

lenientcsv

Lenient CSV parsing in Ruby
Ruby
2
star
32

homebridge-intesisbox

Homebridge plugin for Intesisbox gateways
JavaScript
2
star
33

notpm

Not-quite an NPM registry
Ruby
2
star
34

ucc-openid

Project to write a working UCC OpenID server.
2
star
35

openid_provider_profile

OpenID attribute exchange (AX) for user and profile fields for Drupal's OpenID Provider (http://drupal.org/project/openid_provider)
PHP
2
star
36

gdataplus

Extending GData to provide a nicer, ruby-like interface to certain APIs.
Ruby
2
star
37

webapp

An old Python project to create yet another web framework, here for posterity.
Python
1
star
38

rqrcode-renderer

Ruby
1
star
39

twatter

It's Twitter, but not.
Ruby
1
star
40

xbmc-web

XBMC web interface that doesn't suck (WIP)
CoffeeScript
1
star
41

oidc-token-buildkite-plugin

Shell
1
star
42

xmpr

XMP Reader in Ruby
Ruby
1
star
43

spoj

Some old SPOJ problems
C
1
star
44

menutarget

Easily set a menu item to open in a new window
PHP
1
star
45

nonogrammer

Ruby
1
star
46

nestive-example

Ruby
1
star
47

user_cull

Drupal module to mass delete users by uploading a CSV/list of usernames and emails
1
star
48

railscamp_attendees

Railscamp attendee lists
Ruby
1
star
49

codejam

Some old attempts at Google CodeJam problems
Python
1
star
50

rubygems.rc

Rubygems.org clone made at Railscamp XI
Ruby
1
star
51

homebrew-git-buildkite

Homebrew formula for git-buildkite
Ruby
1
star
52

erroneous

Render errors in rails and cache them in your public directory
Ruby
1
star
53

homebrew-mailcatcher

1
star
54

BDRS

Biological Data Recording System (BDRS), also known as the ALA Citizen Science project
JavaScript
1
star
55

setup-crane-buildkite-plugin

Installs crane for use in Buildkite builds
Shell
1
star
56

hellothisis.dog

HTML
1
star