rspec_junit_formatter 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.md +43 -0
- data/lib/rspec/core/formatters/j_unit_formatter.rb +49 -0
- data/lib/rspec_junit_formatter.rb +8 -0
- metadata +80 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Samuel Cochran
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# RSpec JUnit Formatter
|
2
|
+
|
3
|
+
[RSpec][rspec] results that [Hudson][hudson] can read. Probably a few other CI servers, too.
|
4
|
+
|
5
|
+
Inspired by the work of [Diego Souza][dsouza] on [RSpec Formatters][dsouza/rspec_formatters] after frustration with [CI Reporter][ci_reporter].
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
Install the gem:
|
10
|
+
|
11
|
+
gem install rspec_junit_formatter
|
12
|
+
|
13
|
+
Use it:
|
14
|
+
|
15
|
+
rspec --format RspecJunitFormatter --out rspec.xml
|
16
|
+
|
17
|
+
You'll get an XML file with your results in it.
|
18
|
+
|
19
|
+
## More Permanent Usage
|
20
|
+
|
21
|
+
In your .rspec, usually alongside another formatter, add:
|
22
|
+
|
23
|
+
--format JUnitFormatter
|
24
|
+
--out rspec.xml
|
25
|
+
|
26
|
+
I use it with the excellent [Fuubar formatter][fuubar].
|
27
|
+
|
28
|
+
## Roadmap
|
29
|
+
|
30
|
+
* 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.
|
31
|
+
* This would sit nicely in rspec-core, and has been designed to do so.
|
32
|
+
|
33
|
+
## License
|
34
|
+
|
35
|
+
The MIT License, see [LICENSE][license].
|
36
|
+
|
37
|
+
[rspec]: http://rspec.info/
|
38
|
+
[hudson]: http://hudson-ci.org/
|
39
|
+
[dsouza]: https://github.com/dsouza
|
40
|
+
[dsouza/rspec_formatters]: https://github.com/dsouza/rspec_formatters
|
41
|
+
[ci_reporter]: http://caldersphere.rubyforge.org/ci_reporter/
|
42
|
+
[fuubar]: http://jeffkreeftmeijer.com/2010/fuubar-the-instafailing-rspec-progress-bar-formatter/
|
43
|
+
[license]: https://github.com/sj26/rspec-junit-formatter/blob/master/LICENSE
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# Dumps rspec results as a JUnit XML file.
|
2
|
+
# Based on XML schema: http://windyroad.org/dl/Open%20Source/JUnit.xsd
|
3
|
+
class RSpec::Core::Formatters::JUnitFormatter < RSpec::Core::Formatters::BaseFormatter
|
4
|
+
def xml
|
5
|
+
@xml ||= Builder::XmlMarkup.new :target => output, :indent => 2
|
6
|
+
end
|
7
|
+
|
8
|
+
def start example_count
|
9
|
+
@start = Time.now
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
def dump_summary duration, example_count, failure_count, pending_count
|
14
|
+
super
|
15
|
+
|
16
|
+
xml.instruct!
|
17
|
+
xml.testsuite :tests => example_count, :failures => failure_count, :errors => 0, :time => '%.6f' % duration, :timestamp => @start.iso8601 do
|
18
|
+
xml.properties
|
19
|
+
examples.each do |example|
|
20
|
+
send :"dump_summary_example_#{example.execution_result[:status]}", example
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def xml_example example, &block
|
26
|
+
xml.testcase :classname => example.file_path, :name => example.full_description, :time => '%.6f' % example.execution_result[:run_time], &block
|
27
|
+
end
|
28
|
+
|
29
|
+
def dump_summary_example_passed example
|
30
|
+
xml_example example
|
31
|
+
end
|
32
|
+
|
33
|
+
def dump_summary_example_pending example
|
34
|
+
xml_example example do
|
35
|
+
xml.skipped
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def dump_summary_example_failed example
|
40
|
+
exception = example.execution_result[:exception]
|
41
|
+
backtrace = format_backtrace exception.backtrace, example
|
42
|
+
|
43
|
+
xml_example example do
|
44
|
+
xml.failure :message => exception.to_s, :type => exception.class.name do
|
45
|
+
xml.cdata! "#{exception.message}\n#{backtrace.join "\n"}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec_junit_formatter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Samuel Cochran
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-05-24 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "2.0"
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: builder
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "2.1"
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id002
|
37
|
+
description: RSpec results that Hudson can read.
|
38
|
+
email:
|
39
|
+
- sj26@sj26.com
|
40
|
+
executables: []
|
41
|
+
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files: []
|
45
|
+
|
46
|
+
files:
|
47
|
+
- lib/rspec/core/formatters/j_unit_formatter.rb
|
48
|
+
- lib/rspec_junit_formatter.rb
|
49
|
+
- README.md
|
50
|
+
- LICENSE
|
51
|
+
homepage: http://github.com/sj26/rspec_junit_formatter
|
52
|
+
licenses: []
|
53
|
+
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.3.6
|
71
|
+
requirements: []
|
72
|
+
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 1.7.2
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: RSpec JUnit XML formatter
|
78
|
+
test_files: []
|
79
|
+
|
80
|
+
has_rdoc:
|