rutema 2.0.0.pre4 → 2.0.0.pre5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5900ddbc48f9339395a6fd2fe1b462b1e77eeca
4
- data.tar.gz: 631736e8566668e737b05e3ac167960d8e7914d7
3
+ metadata.gz: 6d048197a4e2235edb7c8e5cb603062d320de8b1
4
+ data.tar.gz: 3b2bafe37e8fd4346c8cfe8fec0e37500ef42179
5
5
  SHA512:
6
- metadata.gz: 1e4226db18b42a03673e1db03621409b0ff00ad64d6f94a489d7fdf03bd015fbdfb0b12333b38bf1c6f24e1cf697f4f571e9a195449fb24b2db0c5d1892154bf
7
- data.tar.gz: c45f4a04267190e0c6573b1076f31eb92a5b90e8f79f62f8c94a07c565a4d602d5ce950816bfa259e2aa5164e27ba0d7cacd3a79a8722b8b82073652cfb12281
6
+ metadata.gz: a6e2dd617d970fabc1e337b183d124652d89157fd2b444ad22df5f9c407d0287c824e3a3cb71fe94c40ccd602cab0b51c28fae716cca2783c1ba6b9073f69a25
7
+ data.tar.gz: dd2efe2c3b843b8276403bc40dfcf150516cdc17b2328713f1d65832a2aba759f7988c5f5712f0aa44d1d78cf566eb1fc2e9bece414b1272be337e7e2060cf2c
@@ -1,3 +1,6 @@
1
+ == 2.0.0.pre5 /2015-09-14
2
+ * Add JUnit format reporter
3
+ * The NUnit format is v3, which means it won't work for most CI plugins
1
4
  == 2.0.0 /2015-09-10
2
5
  * Completely rewritten execution engine
3
6
  * dropped Ruby 1.8.x, 1.9.x support, added 2.x
@@ -14,4 +14,5 @@ lib/rutema/elements/minimal.rb
14
14
  lib/rutema/parsers/xml.rb
15
15
  lib/rutema/reporters/json.rb
16
16
  lib/rutema/reporters/nunit.rb
17
+ lib/rutema/reporters/junit.rb
17
18
  lib/rutema/version.rb
@@ -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 to save the report. Default is 'rutema.results.nunit.xml'
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
 
@@ -3,7 +3,7 @@ module Rutema
3
3
  module Version
4
4
  MAJOR=2
5
5
  MINOR=0
6
- TINY="0.pre4"
6
+ TINY="0.pre5"
7
7
  STRING=[ MAJOR, MINOR, TINY ].join( "." )
8
8
  end
9
9
  end
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.pre4
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