rutema 2.0.0.pre9 → 2.0.0.pre10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: facdf20993574a69732e949a82c4ddfbb0c822a1
4
- data.tar.gz: 15dcee68bb4fd63958512fcee9d2cc0f41d74fc6
3
+ metadata.gz: a435cb8b197971e43324e00bd454b221537711c5
4
+ data.tar.gz: 26ac2971066f82bad55a72bfbbcdcb07fb0da797
5
5
  SHA512:
6
- metadata.gz: 909d1697ecb65b828b853016b20828b63aff7a64b1bac57a5d6167f0ae3677984d845afcdd719a8a74c3a3dae9a3b680c7b9c0246fb7049963745b963fdab8e6
7
- data.tar.gz: 38255ba119a608a644997c473dad6c7c1b2104ea6345fce314c548a740b7462f4f043d2b135589692f5c132b2ba39adbf5d1ef98c07802e0bee7e493f8c18317
6
+ metadata.gz: 2af990da6cc49aea9f3c07010bfce221cb878b776b38ee94672f81bb0a777485e4a5b265cd3c2b4a5c3a8fe966d858c1049b902bc8f6c3815a822f4d874e68d2
7
+ data.tar.gz: c8a0914225440da356b6f0f7abe03507f22d91a6a66df098fd3256b3d69b14410200cc7f2cbb87a3d29aa86193e618c5840535f360130487cf9c48a4ac6c737a
data/History.txt CHANGED
@@ -1,3 +1,5 @@
1
+ == 2.0.0.pre10 /2016-03-21
2
+ * Typed collection for states in block reporters
1
3
  == 2.0.0.pre9 /2016-03-14
2
4
  * Bugfix: JUnit reporter works again
3
5
  == 2.0.0.pre8 /2016-03-09
@@ -11,7 +11,7 @@ module Rutema
11
11
  def initialize params
12
12
  @test=params.fetch(:test,"")
13
13
  @text=params.fetch(:text,"")
14
- @timestamp=params.fetch(:timestamp,0)
14
+ @timestamp=params.fetch(:timestamp,Time.now)
15
15
  end
16
16
 
17
17
  def to_s
@@ -31,6 +31,10 @@ module Rutema
31
31
  end
32
32
  end
33
33
 
34
+ #The Runner continuously sends these when executing tests
35
+ #
36
+ #If there is an engine error (e.g. when parsing) you will get an ErrorMessage, if it is a test error
37
+ #you will get a RunnerMessage with :error in the status.
34
38
  class RunnerMessage<Message
35
39
  attr_accessor :duration,:status,:number,:out,:err
36
40
  def initialize params
@@ -58,6 +62,30 @@ module Rutema
58
62
  end
59
63
  end
60
64
 
65
+ #While executing tests the state of each test is collected in an
66
+ #instance of ReportState and the collection is at the end passed to the available block reporters
67
+ #
68
+ #ReportState assumes the timestamp of the first message, the status of the last message
69
+ #and accumulates the duration reported by all messages in it's collection.
70
+ class ReportState
71
+ attr_accessor :steps
72
+ attr_reader :test,:timestamp,:duration,:status
73
+
74
+ def initialize message
75
+ @test=message.test
76
+ @timestamp=message.timestamp
77
+ @duration=message.duration
78
+ @status=message.status
79
+ @steps=[message]
80
+ end
81
+
82
+ def <<(message)
83
+ @steps<<message
84
+ @duration+=message.duration
85
+ @status=message.status
86
+ end
87
+ end
88
+
61
89
  module Messaging
62
90
  def error identifier,message
63
91
  @queue.push(ErrorMessage.new(:test=>identifier,:text=>message,:timestamp=>Time.now))
@@ -51,7 +51,9 @@ module Rutema
51
51
  end
52
52
  end
53
53
  end
54
-
54
+ #This reporter is always instantiated and collects all messages fired by the rutema engine
55
+ #
56
+ #The collections of errors and states are then at the end of a run fed to the block reporters
55
57
  class Collector<EventReporter
56
58
  attr_reader :errors,:states
57
59
  def initialize params,dispatcher
@@ -63,21 +65,24 @@ module Rutema
63
65
  def update message
64
66
  case message
65
67
  when RunnerMessage
66
- test_state=@states.fetch(message.test,{})
67
- test_state["timestamp"]||=message.timestamp
68
- duration=test_state.fetch("duration",0)+message.duration
69
- test_state["duration"]=duration
70
- test_state["status"]= message.status
71
- steps=test_state.fetch("steps",[])
72
- steps<<message
73
- test_state["steps"]=steps
68
+ test_state=@states[message.test]
69
+ if test_state
70
+ test_state<<message
71
+ else
72
+ test_state=Rutema::ReportState.new(message)
73
+ end
74
74
  @states[message.test]=test_state
75
75
  when ErrorMessage
76
76
  @errors<<message
77
77
  end
78
78
  end
79
79
  end
80
-
80
+ #A very simple event reporter that outputs to the console
81
+ #
82
+ #It has three settings: off, normal and verbose.
83
+ #
84
+ #Example configuration:
85
+ # cfg.reporter={:class=>Rutema::Reporters::Console, "mode"=>"verbose"}
81
86
  class Console<EventReporter
82
87
  def initialize configuration,dispatcher
83
88
  super(configuration,dispatcher)
@@ -108,9 +113,8 @@ module Rutema
108
113
  end
109
114
  def report specs,states,errors
110
115
  failures=[]
111
- states.each do |k,v|
112
- failures<<k if v.fetch("steps",[]).last.status==:error
113
- end
116
+ states.each{|k,v| failures<<v.test if v.status==:error}
117
+
114
118
  unless @silent
115
119
  puts "#{errors.size} errors. #{states.size} test cases executed. #{failures.size} failed"
116
120
  unless failures.empty?
@@ -34,8 +34,8 @@ module Rutema
34
34
  total_duration=0
35
35
  states.each do |k,v|
36
36
  tests<<test_case(k,v)
37
- number_of_failed+=1 if v['status']!=:success
38
- total_duration+=v["duration"].to_f
37
+ number_of_failed+=1 if v.status!=:success
38
+ total_duration+=v.duration.to_f
39
39
  end
40
40
  #<testsuite disabled="0" errors="0" failures="1" hostname="" id=""
41
41
  #name="" package="" skipped="" tests="" time="" timestamp="">
@@ -59,17 +59,17 @@ module Rutema
59
59
  # <error> => test encountered an error
60
60
  #</testcase>
61
61
  element_test=REXML::Element.new("testcase")
62
- element_test.add_attributes("name"=>name,"time"=>state["duration"],"classname"=>@configuration.context[:config_name])
63
- if state['status']!=:success
62
+ element_test.add_attributes("name"=>name,"time"=>state.duration,"classname"=>@configuration.context[:config_name])
63
+ if state.status!=:success
64
64
  fail=REXML::Element.new("failure")
65
- fail.add_attribute("message","Step #{state["steps"].last.number} failed.")
66
- fail.add_text "Step #{state["steps"].last.number} failed."
65
+ fail.add_attribute("message","Step #{state.steps.last.number} failed.")
66
+ fail.add_text "Step #{state.steps.last.number} failed."
67
67
  element_test.add_element(fail)
68
68
  out=REXML::Element.new("system-out")
69
- out.add_text state["steps"].last.out
69
+ out.add_text state.steps.last.out
70
70
  element_test.add_element(out)
71
71
  err=REXML::Element.new("system-err")
72
- err.add_text state["steps"].last.err
72
+ err.add_text state.steps.last.err
73
73
  element_test.add_element(err)
74
74
  end
75
75
  return element_test
@@ -3,7 +3,7 @@ module Rutema
3
3
  module Version
4
4
  MAJOR=2
5
5
  MINOR=0
6
- TINY="0.pre9"
6
+ TINY="0.pre10"
7
7
  STRING=[ MAJOR, MINOR, TINY ].join( "." )
8
8
  end
9
9
  end
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.pre9
4
+ version: 2.0.0.pre10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vassilis Rizopoulos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-14 00:00:00.000000000 Z
11
+ date: 2016-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: patir