rutema 2.0.0.pre4 → 2.0.0.pre5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.txt +3 -0
- data/Manifest.txt +1 -0
- data/lib/rutema/reporters/junit.rb +97 -0
- data/lib/rutema/reporters/nunit.rb +8 -1
- data/lib/rutema/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d048197a4e2235edb7c8e5cb603062d320de8b1
|
4
|
+
data.tar.gz: 3b2bafe37e8fd4346c8cfe8fec0e37500ef42179
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6e2dd617d970fabc1e337b183d124652d89157fd2b444ad22df5f9c407d0287c824e3a3cb71fe94c40ccd602cab0b51c28fae716cca2783c1ba6b9073f69a25
|
7
|
+
data.tar.gz: dd2efe2c3b843b8276403bc40dfcf150516cdc17b2328713f1d65832a2aba759f7988c5f5712f0aa44d1d78cf566eb1fc2e9bece414b1272be337e7e2060cf2c
|
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -0,0 +1,97 @@
|
|
1
|
+
# Copyright (c) 2015 Vassilis Rizopoulos. All rights reserved.
|
2
|
+
require 'rexml/document'
|
3
|
+
require_relative "../core/reporter"
|
4
|
+
|
5
|
+
module Rutema
|
6
|
+
module Reporters
|
7
|
+
#This reporter generates an JUnit style XML result file that can be parsed by CI plugins
|
8
|
+
#
|
9
|
+
#It has been tested with Jenkins (>1.6.20)
|
10
|
+
#
|
11
|
+
#The following configuration keys are used by Rutema::Reporters::JUnit
|
12
|
+
#
|
13
|
+
# filename - the filename to use when saving the report. Default is 'rutema.results.junit.xml'
|
14
|
+
#
|
15
|
+
#Example configuration:
|
16
|
+
#
|
17
|
+
# require "rutema/reporters/junit"
|
18
|
+
# cfg.reporter={:class=>Rutema::Reporters::JUnit,"filename"=>"rutema.junit.xml"}
|
19
|
+
class JUnit<BlockReporter
|
20
|
+
DEFAULT_FILENAME="rutema.results.junit.xml"
|
21
|
+
|
22
|
+
def initialize configuration,dispatcher
|
23
|
+
super(configuration,dispatcher)
|
24
|
+
@filename=configuration.reporters.fetch(self.class,{}).fetch("filename",DEFAULT_FILENAME)
|
25
|
+
end
|
26
|
+
#We get all the data from a test run in here.
|
27
|
+
def report specs,states,errors
|
28
|
+
tests=[]
|
29
|
+
number_of_failed=0
|
30
|
+
total_duration=0
|
31
|
+
states.each do |k,v|
|
32
|
+
tests<<test_case(k,v)
|
33
|
+
number_of_failed+=1 if v['status']!=:success
|
34
|
+
total_duration+=v["duration"].to_f
|
35
|
+
end
|
36
|
+
crashes=errors.map{|error| crash(error[:test],error[:error])}
|
37
|
+
|
38
|
+
|
39
|
+
#<testsuite disabled="0" errors="0" failures="1" hostname="" id=""
|
40
|
+
#name="" package="" skipped="" tests="" time="" timestamp="">
|
41
|
+
attributes={"id"=>@configuration.context[:config_name],
|
42
|
+
"name"=>@configuration.context[:config_name],
|
43
|
+
"errors"=>crashes.size,
|
44
|
+
"failures"=>number_of_failed,
|
45
|
+
"tests"=>specs.size,
|
46
|
+
"time"=>total_duration,
|
47
|
+
"timestamp"=>@configuration.context[:start_time]
|
48
|
+
}
|
49
|
+
element_suite=REXML::Element.new("testsuite")
|
50
|
+
element_suite.add_attributes(attributes)
|
51
|
+
|
52
|
+
crashes.each{|t| element_suite.add_element(t)}
|
53
|
+
tests.each{|t| element_suite.add_element(t)}
|
54
|
+
xmldoc=REXML::Document.new
|
55
|
+
xmldoc<<REXML::XMLDecl.new
|
56
|
+
xmldoc.add_element(element_suite)
|
57
|
+
|
58
|
+
Rutema::Utilities.write_file(@filename,xmldoc.to_s)
|
59
|
+
end
|
60
|
+
private
|
61
|
+
def test_case name,state
|
62
|
+
#<testcase name="" time=""> => the results from executing a test method
|
63
|
+
# <system-out> => data written to System.out during the test run
|
64
|
+
# <system-err> => data written to System.err during the test run
|
65
|
+
# <skipped/> => test was skipped
|
66
|
+
# <failure> => test failed
|
67
|
+
# <error> => test encountered an error
|
68
|
+
#</testcase>
|
69
|
+
element_test=REXML::Element.new("testcase")
|
70
|
+
element_test.add_attributes("name"=>name,"time"=>state["duration"],"classname"=>@configuration.context[:config_name])
|
71
|
+
if state['status']!=:success
|
72
|
+
fail=REXML::Element.new("failure")
|
73
|
+
fail.add_attribute("message","Step #{state["steps"].last["number"]} failed.")
|
74
|
+
fail.text="Step #{state["steps"].last["number"]} failed."
|
75
|
+
element_test.add_element(fail)
|
76
|
+
out=REXML::Element.new("system-out")
|
77
|
+
out.text=state["steps"].last["out"]
|
78
|
+
element_test.add_element(out)
|
79
|
+
err=REXML::Element.new("system-err")
|
80
|
+
err.text=state["steps"].last["err"]
|
81
|
+
element_test.add_element(err)
|
82
|
+
end
|
83
|
+
return element_test
|
84
|
+
end
|
85
|
+
|
86
|
+
def crash name,message
|
87
|
+
failed=REXML::Element.new("testcase")
|
88
|
+
failed.add_attributes("name"=>name,"classname"=>@configuration.context[:config_name],"time"=>0)
|
89
|
+
msg=REXML::Element.new("error")
|
90
|
+
msg.add_attribute("message",message)
|
91
|
+
msg.text=message
|
92
|
+
failed.add_element(msg)
|
93
|
+
return failed
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -6,9 +6,16 @@ module Rutema
|
|
6
6
|
module Reporters
|
7
7
|
#This reporter generates an NUnit style XML result file based on http://nunit.org/files/testresult_30.txt
|
8
8
|
#
|
9
|
+
#Be careful, most of the CI plugins do not understand this NUnit format.
|
10
|
+
#
|
9
11
|
#The following configuration keys are used by Rutema::Reporters::NUnit
|
10
12
|
#
|
11
|
-
# filename - the filename to use
|
13
|
+
# filename - the filename to use when saving the report. Default is 'rutema.results.nunit.xml'
|
14
|
+
#
|
15
|
+
#Example configuration:
|
16
|
+
#
|
17
|
+
# require "rutema/reporters/nunit"
|
18
|
+
# cfg.reporter={:class=>Rutema::Reporters::NUnit,"filename"=>"rutema.nunit.xml"}
|
12
19
|
class NUnit<BlockReporter
|
13
20
|
DEFAULT_FILENAME="rutema.results.nunit.xml"
|
14
21
|
|
data/lib/rutema/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rutema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.pre5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vassilis Rizopoulos
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/rutema/elements/minimal.rb
|
100
100
|
- lib/rutema/parsers/xml.rb
|
101
101
|
- lib/rutema/reporters/json.rb
|
102
|
+
- lib/rutema/reporters/junit.rb
|
102
103
|
- lib/rutema/reporters/nunit.rb
|
103
104
|
- lib/rutema/version.rb
|
104
105
|
homepage: http://github.com/damphyr/rutema
|