rutema 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,7 +1,11 @@
1
+ == 0.9.0 / 2008-09-08
2
+ * Ability to nest scenarios added to the base parser
3
+ * Documentation at
4
+
1
5
  == 0.8.0 / 2008-07-03
2
6
  * Split rutemaweb into own gem
3
7
  * Refactored reporters
4
- * Re-enabled the --step commandline facility of rutemax alowing step-by-step execution and fixed the StepRunner implementation
8
+ * Re-enabled the --step commandline facility of rutemax allowing step-by-step execution and fixed the StepRunner implementation
5
9
 
6
10
  == 0.7.1 / 2008-06-12
7
11
  * Added the ruport_formatter.rb file to the manifest (and consequently to the gem)
data/Manifest.txt CHANGED
@@ -28,14 +28,12 @@ test/distro_test/specs/T001.spec
28
28
  test/distro_test/specs/T002.spec
29
29
  test/distro_test/specs/T003.spec
30
30
  test/distro_test/specs/T004.spec
31
+ test/distro_test/specs/T005.spec
32
+ test/distro_test/specs/include.scenario
33
+ test/distro_test/specs/no_title.spec
34
+ test/distro_test/specs/sample.spec
31
35
  test/rutema.rutema
32
36
  test/rutema.spec
33
- test/samples/check.spec
34
- test/samples/setup.spec
35
- test/samples/teardown.spec
36
- test/samples/test.spec
37
- test/samples/tests/no_title.spec
38
- test/samples/tests/sample.spec
39
37
  test/test_configuration.rb
40
38
  test/test_historian.rb
41
39
  test/test_model.rb
data/README.txt CHANGED
@@ -6,6 +6,7 @@ It allows you to combine test tools while it takes care of logging, reporting, a
6
6
  It's purpose is to make testing in heterogeneous environments easier.
7
7
 
8
8
  For more information look at http://patir.rubyforge.org/rutema
9
+
9
10
  == FEATURES/PROBLEMS:
10
11
  * Unified test execution environment for automated and manual tests
11
12
  * Extensible reports and notifications in various formats (email, rss, pdf, html etc.)
@@ -14,7 +15,6 @@ For more information look at http://patir.rubyforge.org/rutema
14
15
  * A well defined way to create a project specific test specification format
15
16
 
16
17
  == SYNOPSIS:
17
-
18
18
  See http://patir.rubyforge.org/rutema/distro_test.html for an introductory example.
19
19
 
20
20
  == REQUIREMENTS:
@@ -44,7 +44,7 @@ module Rutema
44
44
  def setup= path
45
45
  @setup=check_path(path)
46
46
  end
47
-
47
+
48
48
  #Path to the teardown specification. (optional)
49
49
  #
50
50
  #The teardown test runs after every test.
@@ -54,7 +54,8 @@ module Rutema
54
54
 
55
55
  #Path to the check specification. (optional)
56
56
  #
57
- #The check test runs once in the beginning.
57
+ #The check test runs once in the beginning before all the tests.
58
+ #
58
59
  #If it fails no tests are run.
59
60
  def check= path
60
61
  @check=check_path(path)
data/lib/rutema/db.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # Copyright (c) 2008 Vassilis Rizopoulos, Markus Barchfeld. All rights reserved.
1
2
  $:.unshift File.join(File.dirname(__FILE__),"..")
2
3
  require 'rutema/gems'
3
4
 
@@ -1,3 +1,4 @@
1
+ # Copyright (c) 2007 Vassilis Rizopoulos. All rights reserved.
1
2
  $:.unshift File.join(File.dirname(__FILE__),"..")
2
3
  require 'rutema/model'
3
4
  require 'rutema/system'
@@ -149,7 +149,7 @@ module Rutema
149
149
  #assign
150
150
  @attributes[:cmd]=cmd if cmd
151
151
  @attributes[:text]=txt
152
- @attributes[:number]=0
152
+ @number=0
153
153
  @attributes[:step_type]="step"
154
154
  end
155
155
 
@@ -180,7 +180,9 @@ module Rutema
180
180
  @attributes[:cmd].reset if @attributes[:cmd]
181
181
  end
182
182
  def to_s
183
- "#{self.number} - #{self.step_type} - #{self.status}"
183
+ msg="#{self.number} - #{self.step_type} - #{self.status}"
184
+ msg<<" in #{self.included_in}" if self.has_included_in?
185
+ return msg
184
186
  end
185
187
  end
186
188
 
data/lib/rutema/system.rb CHANGED
@@ -10,7 +10,7 @@ module Rutema
10
10
  #This module defines the version numbers for the library
11
11
  module Version
12
12
  MAJOR=0
13
- MINOR=8
13
+ MINOR=9
14
14
  TINY=0
15
15
  STRING=[ MAJOR, MINOR, TINY ].join( "." )
16
16
  end
@@ -47,18 +47,16 @@ module Rutema
47
47
  def parse_specification param
48
48
  @logger.debug("Loading #{param}")
49
49
  begin
50
- file=false
51
50
  if File.exists?(param)
52
51
  #read the file
53
52
  txt=File.read(param)
54
- file=true
53
+ filename=File.expand_path(param)
55
54
  else
55
+ filename=Dir.pwd
56
56
  #try to parse the parameter
57
57
  txt=param
58
58
  end
59
- spec=parse_case(txt)
60
- spec.filename=""
61
- spec.filename=param if file
59
+ spec=parse_case(txt,filename)
62
60
  raise "Missing required attribute 'name' in specification element" unless spec.has_name? && !spec.name.empty?
63
61
  return spec
64
62
  rescue
@@ -66,10 +64,10 @@ module Rutema
66
64
  raise ParserError,"Error loading #{param}: #{$!.message}"
67
65
  end
68
66
  end
69
-
67
+
70
68
  private
71
69
  #Parses the XML specification of a testcase and creates the corresponding TestSpecification instance
72
- def parse_case xmltxt
70
+ def parse_case xmltxt,filename
73
71
  #the testspec to return
74
72
  spec=TestSpecification.new
75
73
  #read the test spec
@@ -99,7 +97,10 @@ module Rutema
99
97
  spec.requirements=reqs
100
98
  #Get the scenario
101
99
  @logger.debug("Parsing scenario element")
102
- spec.scenario=parse_scenario(xmldoc.elements[ELEM_SCENARIO].to_s) if xmldoc.elements[ELEM_SCENARIO]
100
+ Dir.chdir(File.dirname(filename)) do
101
+ spec.scenario=parse_scenario(xmldoc.elements[ELEM_SCENARIO].to_s) if xmldoc.elements[ELEM_SCENARIO]
102
+ end
103
+ spec.filename=filename
103
104
  return spec
104
105
  end
105
106
  #Validates the XML file from our point of view.
@@ -110,8 +111,10 @@ module Rutema
110
111
  raise ParserError,"missing #{ELEM_DESC} element" unless xmldoc.elements[ELEM_DESC]
111
112
  raise ParserError,"missing #{ELEM_TITLE} element" unless xmldoc.elements[ELEM_TITLE]
112
113
  end
114
+
113
115
  #Parses the scenario XML element and returns the Rutema::TestScenario instance
114
116
  def parse_scenario xmltxt
117
+ @logger.debug("Parsing scenario from #{xmltxt}")
115
118
  scenario=Rutema::TestScenario.new
116
119
  xmldoc=REXML::Document.new( xmltxt )
117
120
  xmldoc.root.attributes.each do |attr,value|
@@ -119,13 +122,25 @@ module Rutema
119
122
  end
120
123
  number=0
121
124
  xmldoc.root.elements.each do |el|
122
- number+=1
123
125
  step=parse_step(el.to_s)
124
- step.number=number
125
- scenario.add_step(step)
126
+ if step.step_type=="include_scenario"
127
+ included_scenario=include_scenario(step)
128
+ included_scenario.steps.each do |st|
129
+ @logger.debug("Adding included step #{st}")
130
+ number+=1
131
+ st.number=number
132
+ st.included_in=step.file
133
+ scenario.add_step(st)
134
+ end
135
+ else
136
+ number+=1
137
+ step.number=number
138
+ scenario.add_step(step)
139
+ end
126
140
  end
127
141
  return scenario
128
142
  end
143
+
129
144
  #Parses xml and returns the Rutema::TestStep instance
130
145
  def parse_step xmltxt
131
146
  xmldoc=REXML::Document.new( xmltxt )
@@ -147,10 +162,23 @@ module Rutema
147
162
  element.attribute(attr,value)
148
163
  end
149
164
  end
165
+
150
166
  def boolean? attribute_value
151
167
  return true if attribute_value=="true" || attribute_value=="false"
152
168
  return false
153
169
  end
170
+
171
+ #handles <include_scenario> elements, adding the steps to the current scenario
172
+ def include_scenario step
173
+ @logger.debug("Including file from #{step}")
174
+ raise ParserError,"missing required attribute file in #{step}" unless step.has_file?
175
+ raise ParserError,"Cannot find #{File.expand_path(step.file)}" unless File.exists?(File.expand_path(step.file))
176
+ #Load the scenario
177
+ step.file=File.expand_path(step.file)
178
+ include_content=File.read(step.file)
179
+ @logger.debug(include_content)
180
+ return parse_scenario(include_content)
181
+ end
154
182
  end
155
183
  #The ExtensibleXMLParser allows you to easily add methods to handle specification elements.
156
184
  #
@@ -8,5 +8,6 @@ configuration.tests=[
8
8
  "../specs/T001.spec",
9
9
  "../specs/T002.spec",
10
10
  "../specs/T003.spec",
11
- "../specs/T004.spec"
11
+ "../specs/T004.spec",
12
+ "../specs/T005.spec"
12
13
  ]
@@ -1,10 +1,11 @@
1
1
  configuration.parser={:class=>Rutema::MinimalXMLParser}
2
- configuration.reporter={:class=>Rutema::ActiveRecordReporter, :database=>"sample.db"}
2
+ configuration.reporter={:class=>Rutema::ActiveRecordReporter, :db=>{:database=>"sample.db"}}
3
3
  configuration.tests=[
4
4
  "../specs/T001.spec",
5
5
  "../specs/T002.spec",
6
6
  "../specs/T003.spec",
7
- "../specs/T004.spec"
7
+ "../specs/T004.spec",
8
+ "../specs/T005.spec"
8
9
  ]
9
10
  configuration.tool={:name=>"test",:path=>".",:configuration=>{:key=>"value"}}
10
11
  configuration.path={:name=>"test",:path=>"."}
@@ -4,5 +4,6 @@ configuration.tests=[
4
4
  "../specs/T001.spec",
5
5
  "../specs/T002.spec",
6
6
  "../specs/T003.spec",
7
- "../specs/T004.spec"
7
+ "../specs/T004.spec",
8
+ "../specs/T005.spec"
8
9
  ]
@@ -3,5 +3,6 @@ configuration.tests=[
3
3
  "../specs/T001.spec",
4
4
  "../specs/T002.spec",
5
5
  "../specs/T003.spec",
6
- "../specs/T004.spec"
6
+ "../specs/T004.spec",
7
+ "../specs/T005.spec"
7
8
  ]
@@ -1,3 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
1
2
  <specification name="T001">
2
3
  <title>T001</title>
3
4
  <description>An echo test</description>
@@ -1,3 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
1
2
  <specification name="T002">
2
3
  <title>T002</title>
3
4
  <description>A command test</description>
@@ -1,3 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
1
2
  <specification name="T003">
2
3
  <title>T003</title>
3
4
  <description>A prompt</description>
@@ -1,3 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
1
2
  <specification name="T004">
2
3
  <title>T004</title>
3
4
  <description>An implicitly attended test</description>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <specification name="T005">
3
+ <title>T005</title>
4
+ <description>Test the include_scenario element</description>
5
+ <scenario>
6
+ <echo>We can now include scenarios in standalone files</echo>
7
+ <include_scenario file="include.scenario"/>
8
+ <echo>This is the 5th step</echo>
9
+ </scenario>
10
+ </specification>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <scenario>
3
+ <echo>This is a step from an included scenario</echo>
4
+ <echo>And another step from the included scenario</echo>
5
+ </scenario>
@@ -1,3 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
1
2
  <specification name="no_title">
2
3
  <description>Expect a parser error</description>
3
4
  <scenario></scenario>
@@ -1,3 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
1
2
  <specification name="sample">
2
3
  <title>Sample specification</title>
3
4
  <description>Something to play with</description>
data/test/test_system.rb CHANGED
@@ -18,6 +18,34 @@ module TestRutema
18
18
  </scenario>
19
19
  </specification>
20
20
  EOT
21
+ INCLUDE_SPEC=<<EOT
22
+ <specification name="include">
23
+ <title>Title</title>
24
+ <description>Description</description>
25
+ <scenario>
26
+ <step/>
27
+ <include_scenario file="#{File.expand_path(File.dirname(__FILE__))}/distro_test/specs/include.scenario"/>
28
+ </scenario>
29
+ </specification>
30
+ EOT
31
+ BAD_INCLUDE_SPEC=<<EOT
32
+ <specification name="bad_include">
33
+ <title>Title</title>
34
+ <description>Description</description>
35
+ <scenario>
36
+ <include_scenario file=unknown.scenario"/>
37
+ </scenario>
38
+ </specification>
39
+ EOT
40
+ MISSING_INCLUDE_SPEC=<<EOT
41
+ <specification name="bad_include">
42
+ <title>Title</title>
43
+ <description>Description</description>
44
+ <scenario>
45
+ <include_scenario/>
46
+ </scenario>
47
+ </specification>
48
+ EOT
21
49
 
22
50
  def test_parse_specification
23
51
  parser=Rutema::BaseXMLParser.new({})
@@ -34,6 +62,16 @@ EOT
34
62
  assert_raise(Rutema::ParserError) { parser.parse_specification("") }
35
63
  assert_raise(Rutema::ParserError) { parser.parse_specification("missing.spec") }
36
64
  end
65
+
66
+ def test_include
67
+ parser=Rutema::BaseXMLParser.new({})
68
+ specification=parser.parse_specification(INCLUDE_SPEC)
69
+ assert_equal(3, specification.scenario.steps.size)
70
+ assert(specification.scenario.steps[2].has_included_in?)
71
+ assert_raise(Rutema::ParserError) { parser.parse_specification(BAD_INCLUDE_SPEC) }
72
+ assert_raise(Rutema::ParserError) { parser.parse_specification(MISSING_INCLUDE_SPEC) }
73
+ end
74
+
37
75
  end
38
76
 
39
77
  class TestExtensibleXMlParser<Test::Unit::TestCase
@@ -91,8 +129,8 @@ EOT
91
129
  coord.run(:all)
92
130
  coord.run(:attended)
93
131
  coord.run(:unattended)
94
- coord.run("samples/tests/sample.spec")
95
- coord.run("samples/tests/no_title.spec")
132
+ coord.run("distro_test/specs/sample.spec")
133
+ coord.run("distro_test/specs/no_title.spec")
96
134
  end
97
135
  assert_equal(1,coord.parse_errors.size)
98
136
  puts coord.to_s if $DEBUG
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.8.0
4
+ version: 0.9.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-07-03 00:00:00 +02:00
12
+ date: 2008-09-08 00:00:00 +02:00
13
13
  default_executable: rutemax
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -82,7 +82,7 @@ dependencies:
82
82
  - !ruby/object:Gem::Version
83
83
  version: 1.7.0
84
84
  version:
85
- description: "== DESCRIPTION: rutema is a test execution tool with a twist. It allows you to combine test tools while it takes care of logging, reporting, archiving of results and formalizes execution of automated and manual tests. It's purpose is to make testing in heterogeneous environments easier. For more information look at http://patir.rubyforge.org/rutema == FEATURES/PROBLEMS: * Unified test execution environment for automated and manual tests * Extensible reports and notifications in various formats (email, rss, pdf, html etc.) * Web frontend and command line report generation tools for browsing the test results database (with rutemaweb) * Comprehensive history of test execution * A well defined way to create a project specific test specification format == SYNOPSIS: See http://patir.rubyforge.org/rutema/distro_test.html for an introductory example. == REQUIREMENTS: * patir (http://patir.rubyforge.org) * mailfactory (http://rubyforge.org/projects/mailfactory/) * activerecord (http://ar.rubyonrails.com/) * sqlite3 (http://rubyforge.org/projects/sqlite-ruby/) * ruport (http://rubyreports.org/) * acts_as_reportable * highline"
85
+ description: "== DESCRIPTION: rutema is a test execution tool with a twist. It allows you to combine test tools while it takes care of logging, reporting, archiving of results and formalizes execution of automated and manual tests. It's purpose is to make testing in heterogeneous environments easier. For more information look at http://patir.rubyforge.org/rutema == FEATURES/PROBLEMS: * Unified test execution environment for automated and manual tests * Extensible reports and notifications in various formats (email, rss, pdf, html etc.) * Web frontend and command line report generation tools for browsing the test results database (with rutemaweb) * Comprehensive history of test execution * A well defined way to create a project specific test specification format == SYNOPSIS: See http://patir.rubyforge.org/rutema/distro_test.html for an introductory example. == REQUIREMENTS: * patir (http://patir.rubyforge.org) * mailfactory (http://rubyforge.org/projects/mailfactory/) * activerecord (http://ar.rubyonrails.com/) * sqlite3 (http://rubyforge.org/projects/sqlite-ruby/) * ruport (http://rubyreports.org/) * acts_as_reportable * highline"
86
86
  email: riva@braveworld.net
87
87
  executables:
88
88
  - rutemax
@@ -125,14 +125,12 @@ files:
125
125
  - test/distro_test/specs/T002.spec
126
126
  - test/distro_test/specs/T003.spec
127
127
  - test/distro_test/specs/T004.spec
128
+ - test/distro_test/specs/T005.spec
129
+ - test/distro_test/specs/include.scenario
130
+ - test/distro_test/specs/no_title.spec
131
+ - test/distro_test/specs/sample.spec
128
132
  - test/rutema.rutema
129
133
  - test/rutema.spec
130
- - test/samples/check.spec
131
- - test/samples/setup.spec
132
- - test/samples/teardown.spec
133
- - test/samples/test.spec
134
- - test/samples/tests/no_title.spec
135
- - test/samples/tests/sample.spec
136
134
  - test/test_configuration.rb
137
135
  - test/test_historian.rb
138
136
  - test/test_model.rb
@@ -1,5 +0,0 @@
1
- <specification name="check">
2
- <title></title>
3
- <description></description>
4
- <scenario></scenario>
5
- </specification>
@@ -1,7 +0,0 @@
1
- <specification name="setup">
2
- <title></title>
3
- <description></description>
4
- <scenario>
5
- <echo>Hello Testing World</echo>
6
- </scenario>
7
- </specification>
@@ -1,7 +0,0 @@
1
- <specification name="teardown">
2
- <title></title>
3
- <description></description>
4
- <scenario>
5
- <echo>Hello Testing World</echo>
6
- </scenario>
7
- </specification>
@@ -1,7 +0,0 @@
1
- <specification name="sample">
2
- <title>Sample specification</title>
3
- <description>Something to play with</description>
4
- <scenario>
5
- <echo>Hello Testing World</echo>
6
- </scenario>
7
- </specification>