rutema 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -1
- data/lib/rutema/reporter.rb +2 -8
- data/lib/rutema/reporters/activerecord.rb +1 -3
- data/lib/rutema/reporters/email.rb +22 -4
- data/lib/rutema/system.rb +52 -33
- data/test/test_reporter.rb +18 -3
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
+
== 0.9.1 / 2008-09-09
|
2
|
+
* Modularisation of element parsing methods introduced.
|
3
|
+
* MinimalXMLParser refactored as example.
|
4
|
+
* Extra element parser modules available in the rutema_elements gem
|
5
|
+
* Cleaned up EmailReporter. Unit tests with Mocha, text report has a better layout
|
6
|
+
|
1
7
|
== 0.9.0 / 2008-09-08
|
2
8
|
* Ability to nest scenarios added to the base parser
|
3
|
-
* Documentation at
|
9
|
+
* Documentation at http://patir.rubyforge.org/rutema/tool_configuration.html
|
4
10
|
|
5
11
|
== 0.8.0 / 2008-07-03
|
6
12
|
* Split rutemaweb into own gem
|
data/lib/rutema/reporter.rb
CHANGED
@@ -12,7 +12,7 @@ module Rutema
|
|
12
12
|
|
13
13
|
#Coordinator will pass the Rutema __configuration__ giving you access to the context which can contain data like headings and build numbers to use in the report. It will also pass the specifications used in the last run so that data like the title and the specification version can be used.
|
14
14
|
#
|
15
|
-
#runner_states is
|
15
|
+
#runner_states is a Hash of Patir::CommandSeqeunceStatus indexed by the specification name containing the stati of the last run (so it contains all the Scenario stati for the loaded tests)
|
16
16
|
#
|
17
17
|
#parse_errors is an Array of {:filename,:error} hashes containing the errors encountered by the parser when loading the specifications
|
18
18
|
def report specifications,runner_states,parse_errors,configuration
|
@@ -21,11 +21,5 @@ module Rutema
|
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
24
|
-
|
25
|
-
msg="Parse errors: #{parse_errors.size}"
|
26
|
-
parse_errors.each{|e| msg<<"\n\t#{e[:filename]}"}
|
27
|
-
msg<<"\nCurrent run:\nScenarios: #{runner_states.size}"
|
28
|
-
# msg<<"\n#{runner_status.summary}"
|
29
|
-
return msg
|
30
|
-
end
|
24
|
+
|
31
25
|
end
|
@@ -10,12 +10,10 @@ module Rutema
|
|
10
10
|
#The ActiveRecordReporter will store the results of a test run in a database using ActiveRecord.
|
11
11
|
#
|
12
12
|
#The DBMSs supported are dependent on the platform: either SQLite3 (MRI) or h2 (jruby)
|
13
|
-
class ActiveRecordReporter
|
13
|
+
class ActiveRecordReporter
|
14
14
|
#The required keys in this reporter's configuration are:
|
15
15
|
# :db - the database configuration. A Hash with the DB adapter information
|
16
16
|
# :db=>{:database=>"sample.rb"}
|
17
|
-
#
|
18
|
-
#Optionally you can pass a Logger instance with the :logger key
|
19
17
|
def initialize definition
|
20
18
|
@logger=definition[:logger]
|
21
19
|
@logger||=Patir.setup_logger
|
@@ -42,8 +42,6 @@ module Rutema
|
|
42
42
|
#customize
|
43
43
|
@subject=definition[:subject]
|
44
44
|
@subject||=""
|
45
|
-
#this is a way to test without sending
|
46
|
-
@dummy=true if definition[:dummy]
|
47
45
|
@logger.info("Reporter '#{self.to_s}' registered")
|
48
46
|
end
|
49
47
|
|
@@ -54,7 +52,7 @@ module Rutema
|
|
54
52
|
|
55
53
|
def report specifications,runner_states,parse_errors,configuration
|
56
54
|
@mail.subject = "#{@subject}"
|
57
|
-
@mail.text =
|
55
|
+
@mail.text = text_report(runner_states,parse_errors)
|
58
56
|
begin
|
59
57
|
if @mail.to.empty?
|
60
58
|
@logger.error("No recipients for the report mail")
|
@@ -63,7 +61,7 @@ module Rutema
|
|
63
61
|
#~ if @password
|
64
62
|
#~ #if a password is defined, use cram_md5 authentication
|
65
63
|
#~ else
|
66
|
-
Net::SMTP.start(@server, @port, @domain) {|smtp| smtp.sendmail(@mail.to_s(),@mail.from,@mail.to)}
|
64
|
+
Net::SMTP.start(@server, @port, @domain) {|smtp| smtp.sendmail(@mail.to_s(),@mail.from,@mail.to)}
|
67
65
|
#~ end
|
68
66
|
end#recipients empty
|
69
67
|
rescue
|
@@ -71,5 +69,25 @@ module Rutema
|
|
71
69
|
end
|
72
70
|
@mail.to_s
|
73
71
|
end
|
72
|
+
private
|
73
|
+
def text_report runner_states,parse_errors
|
74
|
+
msg=""
|
75
|
+
#Report on parse errors
|
76
|
+
msg<<"No parse errors" if parse_errors.empty?
|
77
|
+
msg<<"One parse error:" if parse_errors.size==1
|
78
|
+
msg<<"#{parse_errors.size} parse errors:" if parse_errors.size>1
|
79
|
+
parse_errors.each do |er|
|
80
|
+
msg<<"\n\tin #{er[:filename]} : #{er[:error]}"
|
81
|
+
end
|
82
|
+
msg<<"\n---"
|
83
|
+
#Report on scenarios
|
84
|
+
msg<<"\nNo scenarios in this run" if runner_states.empty?
|
85
|
+
msg<<"\nOne scenario in the current run:" if runner_states.size==1
|
86
|
+
msg<<"\n#{runner_states.size} scenarios in the current run:" if runner_states.size>1
|
87
|
+
runner_states.each do |state|
|
88
|
+
msg<<"\n#{state.summary}\n---"
|
89
|
+
end
|
90
|
+
return msg
|
91
|
+
end
|
74
92
|
end
|
75
93
|
end
|
data/lib/rutema/system.rb
CHANGED
@@ -11,9 +11,52 @@ module Rutema
|
|
11
11
|
module Version
|
12
12
|
MAJOR=0
|
13
13
|
MINOR=9
|
14
|
-
TINY=
|
14
|
+
TINY=1
|
15
15
|
STRING=[ MAJOR, MINOR, TINY ].join( "." )
|
16
16
|
end
|
17
|
+
#The Elements module provides the namespace for the various modules adding parser functionality
|
18
|
+
module Elements
|
19
|
+
#Minimal offers a minimal(chic) set of elements for use in specifications
|
20
|
+
#
|
21
|
+
#These are:
|
22
|
+
# echo
|
23
|
+
# command
|
24
|
+
# prompt
|
25
|
+
module Minimal
|
26
|
+
#echo prints a message on the screen:
|
27
|
+
# <echo text="A meaningful message"/>
|
28
|
+
# <echo>A meaningful message</echo>
|
29
|
+
def element_echo step
|
30
|
+
step.cmd=Patir::RubyCommand.new("echo"){|cmd| cmd.error="";cmd.output="#{step.text}";$stdout.puts(cmd.output) ;:success}
|
31
|
+
end
|
32
|
+
#command executes a shell command
|
33
|
+
# <command cmd="useful_command.exe with parameters", working_directory="some/directory"/>
|
34
|
+
def element_prompt step
|
35
|
+
step.attended=true
|
36
|
+
step.cmd=Patir::RubyCommand.new("prompt") do |cmd|
|
37
|
+
cmd.output=""
|
38
|
+
cmd.error=""
|
39
|
+
if HighLine.new.agree("#{step.text}")
|
40
|
+
step.output="y"
|
41
|
+
:success
|
42
|
+
else
|
43
|
+
step.error="n"
|
44
|
+
:error
|
45
|
+
end#if
|
46
|
+
end#do rubycommand
|
47
|
+
end
|
48
|
+
#prompt asks the user a yes/no question. Answering yes means the step is succesful.
|
49
|
+
# <prompt text="Do you want fries with that?"/>
|
50
|
+
#
|
51
|
+
#A prompt element automatically makes a specification "attended"
|
52
|
+
def element_command step
|
53
|
+
raise ParserError,"missing required attribute cmd in #{step}" unless step.has_cmd?
|
54
|
+
wd=Dir.pwd
|
55
|
+
wd=step.working_directory if step.has_working_directory?
|
56
|
+
step.cmd=Patir::ShellCommand.new(:cmd=>step.cmd,:working_directory=>File.expand_path(wd))
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
17
60
|
#Is raised when an error is found in a specification
|
18
61
|
class ParserError<RuntimeError
|
19
62
|
end
|
@@ -32,7 +75,8 @@ module Rutema
|
|
32
75
|
raise ParserError,"not implemented. You should derive a parser implementation from SpecificationParser!"
|
33
76
|
end
|
34
77
|
end
|
35
|
-
|
78
|
+
|
79
|
+
#BaseXMLParser encapsulates all the XML parsing code
|
36
80
|
class BaseXMLParser<SpecificationParser
|
37
81
|
ELEM_SPEC="specification"
|
38
82
|
ELEM_DESC="specification/description"
|
@@ -205,39 +249,11 @@ module Rutema
|
|
205
249
|
return spec
|
206
250
|
end
|
207
251
|
end
|
208
|
-
#MinimalXMLParser offers three runnable steps in the scenarios
|
252
|
+
#MinimalXMLParser offers three runnable steps in the scenarios
|
253
|
+
#
|
209
254
|
#
|
210
|
-
#echo prints a message on the screen:
|
211
|
-
# <echo text="A meaningful message"/>
|
212
|
-
# <echo>A meaningful message</echo>
|
213
|
-
#command executes a shell command
|
214
|
-
# <command cmd="useful_command.exe with parameters", working_directory="some/directory"/>
|
215
|
-
#prompt asks the user a yes/no question. Anwerings yes means the step is succesful.
|
216
|
-
# <prompt text="Do you want fries with that?"/>
|
217
255
|
class MinimalXMLParser<ExtensibleXMLParser
|
218
|
-
|
219
|
-
step.cmd=Patir::RubyCommand.new("echo"){|cmd| cmd.error="";cmd.output="#{step.text}";$stdout.puts(cmd.output) ;:success}
|
220
|
-
end
|
221
|
-
def element_prompt step
|
222
|
-
step.attended=true
|
223
|
-
step.cmd=Patir::RubyCommand.new("prompt") do |cmd|
|
224
|
-
cmd.output=""
|
225
|
-
cmd.error=""
|
226
|
-
if HighLine.new.agree("#{step.text}")
|
227
|
-
step.output="y"
|
228
|
-
:success
|
229
|
-
else
|
230
|
-
step.error="n"
|
231
|
-
:error
|
232
|
-
end#if
|
233
|
-
end#do rubycommand
|
234
|
-
end
|
235
|
-
def element_command step
|
236
|
-
raise ParserError,"missing required attribute cmd in #{step}" unless step.has_cmd?
|
237
|
-
wd=Dir.pwd
|
238
|
-
wd=step.working_directory if step.has_working_directory?
|
239
|
-
step.cmd=Patir::ShellCommand.new(:cmd=>step.cmd,:working_directory=>File.expand_path(wd))
|
240
|
-
end
|
256
|
+
include Rutema::Elements::Minimal
|
241
257
|
end
|
242
258
|
|
243
259
|
#This class coordinates parsing, execution and reporting of test specifications
|
@@ -552,6 +568,8 @@ module Rutema
|
|
552
568
|
end
|
553
569
|
|
554
570
|
#The "executioner" application class
|
571
|
+
#
|
572
|
+
#Parses the commandline, sets up the configuration and launches Cordinator
|
555
573
|
class RutemaX
|
556
574
|
require 'optparse'
|
557
575
|
def initialize command_line_args
|
@@ -640,4 +658,5 @@ module Rutema
|
|
640
658
|
end
|
641
659
|
end
|
642
660
|
end
|
661
|
+
|
643
662
|
end
|
data/test/test_reporter.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
$:.unshift File.join(File.dirname(__FILE__),"..","lib")
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__),"..","ext")
|
3
2
|
require 'test/unit'
|
4
3
|
require 'ostruct'
|
5
4
|
require 'fileutils'
|
6
|
-
require 'rutema/reporter'
|
7
5
|
require 'rutema/reporters/standard_reporters'
|
6
|
+
require 'rubygems'
|
7
|
+
require 'mocha'
|
8
|
+
require 'net/smtp'
|
8
9
|
#$DEBUG=true
|
9
10
|
module TestRutema
|
10
11
|
class MockCommand
|
@@ -69,8 +70,22 @@ module TestRutema
|
|
69
70
|
@status=[st]
|
70
71
|
end
|
71
72
|
def test_new
|
72
|
-
definition={:server=>"localhost",:port=>25,:recipients=>["test"],:sender=>"rutema",:subject=>"test"
|
73
|
+
definition={:server=>"localhost",:port=>25,:recipients=>["test"],:sender=>"rutema",:subject=>"test"}
|
73
74
|
r=Rutema::EmailReporter.new(definition)
|
75
|
+
Net::SMTP.expects(:start).times(2)
|
76
|
+
assert_nothing_raised() { puts r.report(nil,@status,@parse_errors,nil) }
|
77
|
+
assert_nothing_raised() { puts r.report(nil,[],[],nil) }
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_multiple_scenarios
|
81
|
+
status1=mock()
|
82
|
+
status1.expects(:summary).returns("test1. Status - error. States 3\nStep status summary:\n\t1:'echo' - success\n\t2:'check' - warning\n\t3:'try' - error")
|
83
|
+
status2=mock()
|
84
|
+
status2.expects(:summary).returns("test2. Status - error. States 3\nStep status summary:\n\t1:'echo' - success\n\t2:'check' - success\n\t3:'try' - success")
|
85
|
+
@status=[status1,status2]
|
86
|
+
definition={:server=>"localhost",:port=>25,:recipients=>["test"],:sender=>"rutema",:subject=>"test"}
|
87
|
+
r=Rutema::EmailReporter.new(definition)
|
88
|
+
Net::SMTP.expects(:start)
|
74
89
|
assert_nothing_raised() { puts r.report(nil,@status,@parse_errors,nil) }
|
75
90
|
end
|
76
91
|
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: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vassilis Rizopoulos
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-09-
|
12
|
+
date: 2008-09-09 00:00:00 +02:00
|
13
13
|
default_executable: rutemax
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|