rspec_junit 3.0.3 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/lib/rspec_junit/junit.rb +39 -24
- data/lib/rspec_junit/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f729b0494c3aeecd11d3bf5a6df48052686c84ba
|
4
|
+
data.tar.gz: 264c0d89a7bf1f80679b00692e399d664cc6ccf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad33e37b9f91f2cf934efb758e8f9cb7182464f2775816f5dc7b9cf580e2291920a0beea2f9918ac269a96b1760a6e820030816cb3b01d09146f2c4c091e51e8
|
7
|
+
data.tar.gz: 2ad58ed53cd96daf6afa73f873a3f7b2dff05e68d65b9e74e4fd0e44f9ae5ebc2ffbaee77f6602a52739a928fb1dedf7f9087cfa3197712383cdb55851c45956
|
data/README.md
CHANGED
data/lib/rspec_junit/junit.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
-
#
|
1
|
+
# RSpec formatter for generating results in JUnit format
|
2
|
+
# Inherit from BaseFormatter like the JSON rspec-core formatter.
|
2
3
|
class JUnit < RSpec::Core::Formatters::BaseFormatter
|
3
|
-
RSpec::Core::Formatters.register self, :example_passed, :example_failed,
|
4
|
+
RSpec::Core::Formatters.register self, :example_passed, :example_failed,
|
5
|
+
:example_pending, :dump_summary,
|
6
|
+
:close
|
4
7
|
|
5
8
|
def initialize(output)
|
6
9
|
super
|
7
10
|
@test_suite_results = {}
|
8
|
-
@builder = Builder::XmlMarkup.new :
|
11
|
+
@builder = Builder::XmlMarkup.new indent: 2
|
9
12
|
end
|
10
13
|
|
11
14
|
def example_passed(example_notification)
|
@@ -25,6 +28,17 @@ class JUnit < RSpec::Core::Formatters::BaseFormatter
|
|
25
28
|
@output.puts @builder.target!
|
26
29
|
end
|
27
30
|
|
31
|
+
# close is required to output files correctly.
|
32
|
+
# Use with Process.pid to have unique names
|
33
|
+
# close code modified from: lib/rspec/core/formatters/base_text_formatter.rb
|
34
|
+
def close(_notification)
|
35
|
+
return unless IO === output
|
36
|
+
return if output.closed?
|
37
|
+
|
38
|
+
output.flush
|
39
|
+
output.close unless output == $stdout
|
40
|
+
end
|
41
|
+
|
28
42
|
protected
|
29
43
|
|
30
44
|
def add_to_test_suite_results(example_notification)
|
@@ -34,13 +48,14 @@ class JUnit < RSpec::Core::Formatters::BaseFormatter
|
|
34
48
|
end
|
35
49
|
|
36
50
|
def failure_details_for(example)
|
37
|
-
exception
|
38
|
-
|
39
|
-
|
40
|
-
if
|
41
|
-
|
51
|
+
exception = example.exception
|
52
|
+
return '' if exception.nil?
|
53
|
+
backtrace = ''
|
54
|
+
if exception.backtrace # may be nil
|
55
|
+
backtrace = RSpec::Core::BacktraceFormatter.new.format_backtrace exception.backtrace
|
56
|
+
backtrace = "\n#{backtrace.join("\n")}"
|
42
57
|
end
|
43
|
-
exception.
|
58
|
+
"\n#{exception.class.name}\n#{exception.message}#{backtrace}"
|
44
59
|
end
|
45
60
|
|
46
61
|
# utility methods
|
@@ -56,14 +71,14 @@ class JUnit < RSpec::Core::Formatters::BaseFormatter
|
|
56
71
|
# methods to build the xml for test suites and individual tests
|
57
72
|
|
58
73
|
def build_results(duration, example_count, failure_count, pending_count)
|
59
|
-
@builder.instruct! :xml, :
|
74
|
+
@builder.instruct! :xml, version: '1.0', encoding: 'UTF-8'
|
60
75
|
@builder.testsuites(
|
61
|
-
:
|
62
|
-
:
|
63
|
-
:
|
64
|
-
:
|
65
|
-
:
|
66
|
-
:
|
76
|
+
errors: 0,
|
77
|
+
failures: failure_count,
|
78
|
+
skipped: pending_count,
|
79
|
+
tests: example_count,
|
80
|
+
time: duration,
|
81
|
+
timestamp: Time.now.iso8601) do
|
67
82
|
build_all_suites
|
68
83
|
end
|
69
84
|
end
|
@@ -79,12 +94,12 @@ class JUnit < RSpec::Core::Formatters::BaseFormatter
|
|
79
94
|
skipped_count = JUnit.count_in_suite_of_type(tests, :pending)
|
80
95
|
|
81
96
|
@builder.testsuite(
|
82
|
-
:
|
83
|
-
:
|
84
|
-
:
|
85
|
-
:
|
86
|
-
:
|
87
|
-
:
|
97
|
+
location: tests.first.example_group.location,
|
98
|
+
name: suite_name,
|
99
|
+
tests: tests.size,
|
100
|
+
errors: 0,
|
101
|
+
failures: failure_count,
|
102
|
+
skipped: skipped_count) do
|
88
103
|
@builder.properties
|
89
104
|
build_all_tests tests
|
90
105
|
end
|
@@ -102,7 +117,7 @@ class JUnit < RSpec::Core::Formatters::BaseFormatter
|
|
102
117
|
test_status = test.metadata[:execution_result].status
|
103
118
|
location = test.location
|
104
119
|
|
105
|
-
@builder.testcase(:
|
120
|
+
@builder.testcase(name: test_name, time: execution_time, location: location) do
|
106
121
|
case test_status
|
107
122
|
when :pending
|
108
123
|
@builder.skipped
|
@@ -115,7 +130,7 @@ class JUnit < RSpec::Core::Formatters::BaseFormatter
|
|
115
130
|
def build_failed_test(test)
|
116
131
|
failure_message = "failed #{test.metadata[:full_description]}"
|
117
132
|
|
118
|
-
@builder.failure(:
|
133
|
+
@builder.failure(message: failure_message, type: 'failed') do
|
119
134
|
@builder.cdata!(failure_details_for(test))
|
120
135
|
end
|
121
136
|
end
|
data/lib/rspec_junit/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec_junit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nat Ritmeyer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-10-
|
12
|
+
date: 2015-10-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|