rutema 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.6.0 / 2008-02-27
2
+ * Added Rutema::ExtensibleParser - this parser simplifies parser creation immensely. Check the documentation for details
3
+ * Corrected some english spelling mistakes (hey, we're not native speakers)
4
+ * Fixed an issue with AR cached connections that interfered with unit tests
1
5
  == 0.5.0 / 2008-02-26
2
6
  * activerecord reporter is now loaded by default (no need to require it in the configuration file)
3
7
  * bugfix: step names correctly written in the database
data/README.txt CHANGED
@@ -6,7 +6,7 @@ Rutema provides the basis for building tools that can manage the execution of te
6
6
 
7
7
  It's purpose is to provide a set of classes and a framework that will allow testers to specify and execute tests in heterogeneous testing environments.
8
8
 
9
- Rutema will allows you to combine tools, takes care of logging, reporting, archiving of results and formalizes execution of automated and manual tests.
9
+ Rutema allows you to combine tools while it takes care of logging, reporting, archiving of results and formalizes execution of automated and manual tests.
10
10
 
11
11
  For more information look at http://patir.rubyforge.org/rutema
12
12
 
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ Hoe.new('rutema', "#{Rutema::Version::STRING}") do |p|
14
14
  p.description = p.paragraphs_of('README.txt', 1..5).join("\n\n")
15
15
  p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
16
16
  p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
17
- p.extra_deps<<['patir',">=0.5.2"]
17
+ p.extra_deps<<['patir',">=0.5.3"]
18
18
  p.extra_deps<<['highline']
19
19
  p.extra_deps<<['mailfactory']
20
20
  p.extra_deps<<['activerecord']
@@ -52,7 +52,7 @@ module Rutema
52
52
  end
53
53
  end#parse_command_line
54
54
  end
55
-
55
+
56
56
  class Historian
57
57
  def initialize configuration,logger=nil
58
58
  @logger=logger
@@ -64,9 +64,9 @@ module Rutema
64
64
  def history mode
65
65
  case mode
66
66
  when "all"
67
- table=Model::Scenario.report_table(:all)
68
- @logger.warn("No entries found") if table.empty?
69
- ret=Ruport::Data::Grouping(beautify(table),:by=>"run_id")
67
+ table=Model::Scenario.report_table(:all)
68
+ @logger.warn("No entries found") if table.empty?
69
+ ret=Ruport::Data::Grouping(beautify(table),:by=>"run_id")
70
70
  when String
71
71
  ret=per_spec(mode)
72
72
  end
@@ -97,12 +97,16 @@ module Rutema
97
97
  def connect
98
98
  ActiveRecord::Base.logger = @logger
99
99
  if @configuration.source
100
- if File.exist?(@configuration.source)
101
- @logger.info("Connecting with database '#{@configuration.source}'")
102
- ActiveRecord::Base.establish_connection(:adapter=>"sqlite3", :database=>@configuration.source )
100
+ if ActiveRecord::Base.connection
101
+ @logger.info("Using cached database connection")
103
102
  else
104
- @logger.fatal("Could not find #{@configuration.source}")
105
- exit 1
103
+ if File.exist?(@configuration.source) || @configuration.source==":memory:"
104
+ @logger.info("Connecting with database '#{@configuration.source}'")
105
+ ActiveRecord::Base.establish_connection(:adapter=>"sqlite3", :database=>@configuration.source )
106
+ else
107
+ @logger.fatal("Could not find #{@configuration.source}")
108
+ exit 1
109
+ end
106
110
  end
107
111
  else
108
112
  @logger.fatal("No database source defined in the configuration")
@@ -97,7 +97,11 @@ module Rutema
97
97
  end
98
98
 
99
99
  def attended?
100
- return @attributes[:attended]
100
+ ret=@attributes[:attended]
101
+ @steps.each do |step|
102
+ ret=true if step.attended?
103
+ end
104
+ return ret
101
105
  end
102
106
 
103
107
  def add_step step
@@ -108,7 +112,7 @@ module Rutema
108
112
  def steps= array_of_steps
109
113
  @steps=array_of_steps
110
114
  @steps.each do |step|
111
- @attended=true if step.attended?
115
+ @attributes[:attended]=true if step.attended?
112
116
  end
113
117
  end
114
118
  end
data/lib/rutema/system.rb CHANGED
@@ -15,7 +15,7 @@ module Rutema
15
15
  #This module defines the version numbers for the library
16
16
  module Version
17
17
  MAJOR=0
18
- MINOR=5
18
+ MINOR=6
19
19
  TINY=0
20
20
  STRING=[ MAJOR, MINOR, TINY ].join( "." )
21
21
  end
@@ -153,48 +153,65 @@ module Rutema
153
153
  return false
154
154
  end
155
155
  end
156
-
157
- #MinimalXMLParser offers three runnable steps in the scenarios:
156
+ #The ExtensibleXMLParser allows you to easily add methods to handle specification elements.
158
157
  #
159
- #echo prints a message on the screen:
160
- # <echo text="A meaningful message"/>
161
- # <echo>A meaningful message</echo>
162
- #command executes a shell command
163
- # <command cmd="useful_command.exe with parameters", working_directory="some/directory"/>
164
- #prompt asks the user a yes/no question. Anwerings yes means the step is succesfull.
165
- # <prompt text="Do you want fries with that?"/>
166
- class MinimalXMLParser<BaseXMLParser
158
+ #A method element_foo(step) allows you to add behaviour for <foo> scenario elements.
159
+ #
160
+ #The method will receive a Rutema::TestStep instance.
161
+ class ExtensibleXMLParser<BaseXMLParser
167
162
  def parse_specification param
168
163
  spec = super(param)
169
164
  #change into the directory the spec is in to handle relative paths correctly
170
165
  Dir.chdir(File.dirname(File.expand_path(spec.filename))) do |path|
166
+ #iterate through the steps
171
167
  spec.scenario.steps.each do |step|
172
- case step.step_type
173
- when "echo"
174
- step.cmd=Patir::RubyCommand.new("echo"){|cmd| cmd.output="#{step.text}";$stdout.puts(cmd.output) ;:success}
175
- when "command"
176
- raise ParserError,"missing required attribute cmd in #{step}" unless step.has_cmd?
177
- wd=Dir.pwd
178
- wd=step.working_directory if step.has_working_directory?
179
- step.cmd=Patir::ShellCommand.new(:cmd=>step.cmd,:working_directory=>File.expand_path(wd))
180
- when "prompt"
181
- step.attended=true
182
- spec.scenario.attended=true
183
- step.cmd=Patir::RubyCommand.new("prompt") do |cmd|
184
- cmd.output=""
185
- cmd.error=""
186
- if HighLine.new.agree("#{step.text}?")
187
- :success
188
- else
189
- :error
190
- end#if
191
- end#do rubycommand
192
- end#case
193
- end#do spec.scenario.steps
168
+ #do we have a method to handle the element?
169
+ if respond_to?(:"element_#{step.step_type}")
170
+ begin
171
+ self.send(:"element_#{step.step_type}",step)
172
+ rescue
173
+ raise ParserException, $!.message
174
+ end
175
+ else
176
+ raise ParserException, "No method element_#{step.step_type} to handle #{step.step_type}"
177
+ end
178
+ end
194
179
  end
195
180
  return spec
196
181
  end
197
182
  end
183
+ #MinimalXMLParser offers three runnable steps in the scenarios:
184
+ #
185
+ #echo prints a message on the screen:
186
+ # <echo text="A meaningful message"/>
187
+ # <echo>A meaningful message</echo>
188
+ #command executes a shell command
189
+ # <command cmd="useful_command.exe with parameters", working_directory="some/directory"/>
190
+ #prompt asks the user a yes/no question. Anwerings yes means the step is succesful.
191
+ # <prompt text="Do you want fries with that?"/>
192
+ class MinimalXMLParser<ExtensibleXMLParser
193
+ def element_echo step
194
+ step.cmd=Patir::RubyCommand.new("echo"){|cmd| cmd.output="#{step.text}";$stdout.puts(cmd.output) ;:success}
195
+ end
196
+ def element_prompt step
197
+ step.attended=true
198
+ step.cmd=Patir::RubyCommand.new("prompt") do |cmd|
199
+ cmd.output=""
200
+ cmd.error=""
201
+ if HighLine.new.agree("#{step.text}?")
202
+ :success
203
+ else
204
+ :error
205
+ end#if
206
+ end#do rubycommand
207
+ end
208
+ def element_command step
209
+ raise ParserError,"missing required attribute cmd in #{step}" unless step.has_cmd?
210
+ wd=Dir.pwd
211
+ wd=step.working_directory if step.has_working_directory?
212
+ step.cmd=Patir::ShellCommand.new(:cmd=>step.cmd,:working_directory=>File.expand_path(wd))
213
+ end
214
+ end
198
215
 
199
216
  #This class coordinates parsing, execution and reporting of test specifications
200
217
  class Coordinator
@@ -269,7 +286,7 @@ module Rutema
269
286
  t.join
270
287
  end
271
288
  end
272
-
289
+
273
290
  #returns true if all scenarios in the last run were succesful
274
291
  def last_run_a_success?
275
292
  return @runner.success?
@@ -391,7 +408,7 @@ module Rutema
391
408
  @states["#{name}_setup"]=run_scenario("#{name}_setup",@setup)
392
409
  @states["#{name}_setup"].sequence_id="s#{@number_of_runs}"
393
410
  if @states["#{name}_setup"].executed?
394
- #do not execute the scenario unless the setup was succesfull
411
+ #do not execute the scenario unless the setup was succesful
395
412
  if @states["#{name}_setup"].success?
396
413
  @logger.info("Scenario for #{name}")
397
414
  @states[name]=run_scenario(name,scenario)
@@ -422,8 +439,8 @@ module Rutema
422
439
  @states.clear
423
440
  @number_of_runs=0
424
441
  end
425
-
426
- #returns true if all the scenarios in the last run were succesfull or if nothing was run yet
442
+
443
+ #returns true if all the scenarios in the last run were succesful or if nothing was run yet
427
444
  def success?
428
445
  @success=true
429
446
  @states.each do |k,v|
@@ -580,12 +597,12 @@ module Rutema
580
597
  @logger.info("Report:\n#{@coordinator.to_s}")
581
598
  @coordinator.report
582
599
  if @coordinator.parse_errors.empty? && @coordinator.last_run_a_success?
600
+ @logger.info("All tests succesful")
583
601
  exit 0
584
602
  else
585
- @logger.warn("Not all tests were succesfull")
603
+ @logger.warn("Not all tests were succesful")
586
604
  exit 1
587
605
  end
588
606
  end
589
607
  end
590
-
591
608
  end
@@ -148,17 +148,7 @@ module Rutema
148
148
  end
149
149
  end
150
150
  def start_ramaze
151
- dbfile=ARGV.shift
152
- if !dbfile
153
- puts "please provide a database filename"
154
- exit 0
155
- end
156
- if File.exist?(dbfile)
157
- ActiveRecord::Base.establish_connection(:adapter=>"sqlite3", :database=>File.expand_path(dbfile) )
158
- Dir.chdir(File.dirname(__FILE__)) do
159
- Ramaze.start :force=>true#,:adapter=>:thin
160
- end
161
- else
162
- $stderr.puts "Can't find database file '#{dbfile}'"
151
+ Dir.chdir(File.dirname(__FILE__)) do
152
+ Ramaze.start :force=>true#,:adapter=>:thin
163
153
  end
164
154
  end
@@ -21,7 +21,7 @@ module TestRutema
21
21
  h=Rutema::Historian.new(@configuration)
22
22
  assert_not_nil( h.history("all"), "There should be some history there" )
23
23
  assert_not_nil(h.history("TC001"), "TC001 should have some history" )
24
- assert_nil(h.history("test5"), "NO history expected of test5" )
24
+ assert_nil(h.history("test5"), "No history expected of test5" )
25
25
  puts h.history("all")
26
26
  puts h.history("TC002")
27
27
  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.5.0
4
+ version: 0.6.0
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-02-26 00:00:00 +01:00
12
+ date: 2008-02-27 00:00:00 +01:00
13
13
  default_executable: rutemax
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -19,7 +19,7 @@ dependencies:
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.5.2
22
+ version: 0.5.3
23
23
  version:
24
24
  - !ruby/object:Gem::Dependency
25
25
  name: highline
@@ -93,7 +93,7 @@ dependencies:
93
93
  - !ruby/object:Gem::Version
94
94
  version: 1.5.0
95
95
  version:
96
- description: "== DESCRIPTION: Rutema provides the basis for building tools that can manage the execution of tests as well as an example implementation as proof-of-concept for the ideas behind it. It's purpose is to provide a set of classes and a framework that will allow testers to specify and execute tests in heterogeneous testing environments. Rutema will allows you to combine tools, takes care of logging, reporting, archiving of results and formalizes execution of automated and manual tests. For more information look at http://patir.rubyforge.org/rutema == FEATURES/PROBLEMS:"
96
+ description: "== DESCRIPTION: Rutema provides the basis for building tools that can manage the execution of tests as well as an example implementation as proof-of-concept for the ideas behind it. It's purpose is to provide a set of classes and a framework that will allow testers to specify and execute tests in heterogeneous testing environments. Rutema allows you to combine tools while it takes care of logging, reporting, archiving of results and formalizes execution of automated and manual tests. For more information look at http://patir.rubyforge.org/rutema == FEATURES/PROBLEMS:"
97
97
  email: riva@braveworld.net
98
98
  executables:
99
99
  - rutemax