rutema 2.0.0.pre3 → 2.0.0.pre4
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 +2 -0
- data/lib/rutema/application.rb +3 -1
- data/lib/rutema/core/reporter.rb +19 -3
- data/lib/rutema/core/runner.rb +1 -1
- data/lib/rutema/reporters/json.rb +34 -0
- data/lib/rutema/reporters/nunit.rb +96 -0
- data/lib/rutema/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5900ddbc48f9339395a6fd2fe1b462b1e77eeca
|
4
|
+
data.tar.gz: 631736e8566668e737b05e3ac167960d8e7914d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e4226db18b42a03673e1db03621409b0ff00ad64d6f94a489d7fdf03bd015fbdfb0b12333b38bf1c6f24e1cf697f4f571e9a195449fb24b2db0c5d1892154bf
|
7
|
+
data.tar.gz: c45f4a04267190e0c6573b1076f31eb92a5b90e8f79f62f8c94a07c565a4d602d5ce950816bfa259e2aa5164e27ba0d7cacd3a79a8722b8b82073652cfb12281
|
data/History.txt
CHANGED
@@ -9,6 +9,9 @@
|
|
9
9
|
* pre3:
|
10
10
|
* errors now affect the rutema exit code (before it was only test failures)
|
11
11
|
* single test execution works with expected relative paths
|
12
|
+
* pre4:
|
13
|
+
* NUnit-style XML reporter
|
14
|
+
* JSON reporter
|
12
15
|
|
13
16
|
== 1.3.0 /2012-11-28
|
14
17
|
* remove most of the gem dependencies by not requiring parsers and reporters in the core
|
data/Manifest.txt
CHANGED
data/lib/rutema/application.rb
CHANGED
@@ -9,7 +9,9 @@ module Rutema
|
|
9
9
|
parse_command_line(command_line_args)
|
10
10
|
@configuration=Rutema::Configuration.new(@config_file)
|
11
11
|
@configuration.context||={}
|
12
|
-
@configuration.context[:config_file]=File.
|
12
|
+
@configuration.context[:config_file]=File.expand_path(@config_file)
|
13
|
+
@configuration.context[:config_name]=File.basename(@config_file)
|
14
|
+
@configuration.context[:start_time]=Time.now
|
13
15
|
@configuration.reporters||={}
|
14
16
|
@configuration.reporters[Rutema::Reporters::Console]||={:class=>Rutema::Reporters::Console, "silent"=>@silent} unless @bare
|
15
17
|
@configuration.reporters[Rutema::Reporters::Summary]||={:class=>Rutema::Reporters::Summary, "silent"=>(@silent||@bare)}
|
data/lib/rutema/core/reporter.rb
CHANGED
@@ -57,8 +57,16 @@ module Rutema
|
|
57
57
|
if data[:error]
|
58
58
|
@errors<<data
|
59
59
|
elsif data[:test] && data['status']
|
60
|
-
|
61
|
-
|
60
|
+
test_state=@states.fetch(data[:test],{})
|
61
|
+
test_state["timestamp"]||=data[:timestamp]
|
62
|
+
duration=test_state.fetch("duration",0)+data["duration"]
|
63
|
+
test_state["duration"]=duration
|
64
|
+
test_state["status"]= data["status"]
|
65
|
+
steps=test_state.fetch("steps",[])
|
66
|
+
steps<<data
|
67
|
+
test_state["steps"]=steps
|
68
|
+
|
69
|
+
@states[data[:test]]=test_state
|
62
70
|
end
|
63
71
|
end
|
64
72
|
end
|
@@ -97,7 +105,7 @@ module Rutema
|
|
97
105
|
def report specs,states,errors
|
98
106
|
failures=[]
|
99
107
|
states.each do |k,v|
|
100
|
-
failures<<k if v.last['status']==:error
|
108
|
+
failures<<k if v.fetch("steps",[]).last['status']==:error
|
101
109
|
end
|
102
110
|
unless @silent
|
103
111
|
puts "#{errors.size} errors. #{states.size} test cases executed. #{failures.size} failed"
|
@@ -110,4 +118,12 @@ module Rutema
|
|
110
118
|
end
|
111
119
|
end
|
112
120
|
end
|
121
|
+
|
122
|
+
module Utilities
|
123
|
+
require "fileutils"
|
124
|
+
def self.write_file filename,content
|
125
|
+
FileUtils.mkdir_p(File.dirname(filename),:verbose=>false)
|
126
|
+
File.open(filename, 'wb') {|f| f.write(content) }
|
127
|
+
end
|
128
|
+
end
|
113
129
|
end
|
data/lib/rutema/core/runner.rb
CHANGED
@@ -17,9 +17,9 @@ module Rutema
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def run spec
|
20
|
-
state={'start_time'=>Time.now, "sequence_id"=>@number_of_runs,:test=>spec.name}
|
21
20
|
steps=[]
|
22
21
|
status=:success
|
22
|
+
state={'start_time'=>Time.now, "sequence_id"=>@number_of_runs,:test=>spec.name}
|
23
23
|
message(:test=>spec.name,'phase'=>'started')
|
24
24
|
if @setup
|
25
25
|
message(:test=>spec.name,'phase'=>'setup')
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Copyright (c) 2007-2010 Vassilis Rizopoulos. All rights reserved.
|
2
|
+
require 'json'
|
3
|
+
require_relative "../core/reporter"
|
4
|
+
|
5
|
+
module Rutema
|
6
|
+
module Reporters
|
7
|
+
#Experimental reporter used to dump the data of a run on disk
|
8
|
+
#
|
9
|
+
#The following configuration keys are used by Rutema::Reporters::JSON
|
10
|
+
#
|
11
|
+
# filename - the filename to use to save the YAML dump. Default is 'rutema.results.json'
|
12
|
+
class JSON<Rutema::Reporters::BlockReporter
|
13
|
+
#Default report filename
|
14
|
+
DEFAULT_FILENAME="rutema.results.json"
|
15
|
+
|
16
|
+
def initialize configuration,dispatcher
|
17
|
+
super(configuration,dispatcher)
|
18
|
+
@filename=configuration.reporters.fetch(self.class,{}).fetch("filename",DEFAULT_FILENAME)
|
19
|
+
end
|
20
|
+
#We get all the data from a test run in here.
|
21
|
+
def report specs,states,errors
|
22
|
+
run_entry={}
|
23
|
+
run_entry["specs"]=specs.size
|
24
|
+
if @configuration && @configuration.context
|
25
|
+
run_entry["context"]=@configuration.context
|
26
|
+
end
|
27
|
+
run_entry["errors"]=errors
|
28
|
+
run_entry["states"]=states
|
29
|
+
|
30
|
+
Rutema::Utilities.write_file(@filename,::JSON.dump(run_entry))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,96 @@
|
|
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 NUnit style XML result file based on http://nunit.org/files/testresult_30.txt
|
8
|
+
#
|
9
|
+
#The following configuration keys are used by Rutema::Reporters::NUnit
|
10
|
+
#
|
11
|
+
# filename - the filename to use to save the report. Default is 'rutema.results.nunit.xml'
|
12
|
+
class NUnit<BlockReporter
|
13
|
+
DEFAULT_FILENAME="rutema.results.nunit.xml"
|
14
|
+
|
15
|
+
def initialize configuration,dispatcher
|
16
|
+
super(configuration,dispatcher)
|
17
|
+
@filename=configuration.reporters.fetch(self.class,{}).fetch("filename",DEFAULT_FILENAME)
|
18
|
+
end
|
19
|
+
#We get all the data from a test run in here.
|
20
|
+
def report specs,states,errors
|
21
|
+
tests=[]
|
22
|
+
run_status=:success
|
23
|
+
number_of_failed=0
|
24
|
+
states.each do |k,v|
|
25
|
+
tests<<test_case(k,v)
|
26
|
+
number_of_failed+=1 if v['status']!=:success
|
27
|
+
end
|
28
|
+
|
29
|
+
run_status=:error if number_of_failed>0
|
30
|
+
failures=errors.map{|error| failure("In #{error[:test]}\n#{error[:error]}")}
|
31
|
+
run_status=:error unless failures.empty?
|
32
|
+
|
33
|
+
attributes={"name"=>@configuration.context["config_name"],
|
34
|
+
"fullname"=>@configuration.context["config_file"],
|
35
|
+
"testcasecount"=>specs.size,
|
36
|
+
"result"=>nunit_result(run_status),
|
37
|
+
"total"=>specs.size,
|
38
|
+
"passed"=>specs.size-number_of_failed-failures.size,
|
39
|
+
"failed"=>number_of_failed,
|
40
|
+
"skipped"=>failures.size
|
41
|
+
}
|
42
|
+
#<test-run id="" name="" fullname="" testcasecount=""
|
43
|
+
#result="" time="" run-date="YYYY-MM-DD" start-time="HH:MM:SS">
|
44
|
+
#total="18" passed="12" failed="2" inconclusive="1" skipped="3"
|
45
|
+
element_run=REXML::Element.new("test-run")
|
46
|
+
element_run.add_attributes(attributes)
|
47
|
+
|
48
|
+
#<test-suite type="rutema" id="" name="" fullname="" testcasecount="" result="" time="">
|
49
|
+
#<failure>
|
50
|
+
# <message></message>
|
51
|
+
#</failure>
|
52
|
+
element_suite=REXML::Element.new("test-suite")
|
53
|
+
element_suite.add_attributes(attributes)
|
54
|
+
|
55
|
+
failures.each{|t| element_suite.add_element(t)}
|
56
|
+
tests.each{|t| element_suite.add_element(t)}
|
57
|
+
element_run.add_element(element_suite)
|
58
|
+
xmldoc=REXML::Document.new
|
59
|
+
xmldoc<<REXML::XMLDecl.new
|
60
|
+
xmldoc.add_element(element_run)
|
61
|
+
|
62
|
+
Rutema::Utilities.write_file(@filename,xmldoc.to_s)
|
63
|
+
end
|
64
|
+
private
|
65
|
+
def test_case name,state
|
66
|
+
#<test-case id="" name="" result="" time="">
|
67
|
+
#<failure>
|
68
|
+
# <message></message>
|
69
|
+
#</failure>
|
70
|
+
#</test-case>
|
71
|
+
element_test=REXML::Element.new("test-case")
|
72
|
+
element_test.add_attributes( "id"=>name,"name"=>name,"result"=>nunit_result(state['status']),"time"=>state["duration"])
|
73
|
+
if state['status']!=:success
|
74
|
+
msg="Step #{state["steps"].last["number"]} failed."
|
75
|
+
msg<<"\nOut:\n#{state["steps"].last["out"]}" unless state["steps"].last["out"].empty?
|
76
|
+
msg<<"\nErr:\n#{state["steps"].last["err"]}"
|
77
|
+
element_test.add_element(failure(msg))
|
78
|
+
end
|
79
|
+
return element_test
|
80
|
+
end
|
81
|
+
|
82
|
+
def nunit_result status
|
83
|
+
return "Passed" unless status!=:success
|
84
|
+
return "Failed"
|
85
|
+
end
|
86
|
+
|
87
|
+
def failure message
|
88
|
+
failed=REXML::Element.new("failure")
|
89
|
+
msg=REXML::Element.new("message")
|
90
|
+
msg.text=message
|
91
|
+
failed.add_element(msg)
|
92
|
+
return failed
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/lib/rutema/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.pre4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vassilis Rizopoulos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: patir
|
@@ -98,6 +98,8 @@ files:
|
|
98
98
|
- lib/rutema/core/runner.rb
|
99
99
|
- lib/rutema/elements/minimal.rb
|
100
100
|
- lib/rutema/parsers/xml.rb
|
101
|
+
- lib/rutema/reporters/json.rb
|
102
|
+
- lib/rutema/reporters/nunit.rb
|
101
103
|
- lib/rutema/version.rb
|
102
104
|
homepage: http://github.com/damphyr/rutema
|
103
105
|
licenses:
|