rutema 1.0.3 → 1.0.4

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.
@@ -1,10 +1,12 @@
1
+ == 1.0.4 / 2008-11-7
2
+ * Added functionality that allows ignoring the result of a step. The step is considered always successful
1
3
  == 1.0.3 / 2008-10-28
2
4
  * The name of the configuration file is added in the context information - can be used to group results together in cases where there are multiple configurations
3
5
  * Context is now stored as a Hash
4
6
  * EmailReporter now displays a footer as defined in it's configuration
5
7
  == 1.0.2 / 2008-10-23
6
8
  * Bugfix in ActiveRecordReporter: \000 sequences produce exceptions when inserting.
7
- * Output and error from commands is now more strctly sanitized.
9
+ * Output and error from commands is now more strictly sanitized.
8
10
  == 1.0.1 / 2008-10-13
9
11
  * rutema_upgrader - Bug: update not performed - fixed
10
12
  == 1.0.0 / 2008-10-06
@@ -28,6 +28,7 @@ test/distro_test/specs/T002.spec
28
28
  test/distro_test/specs/T003.spec
29
29
  test/distro_test/specs/T004.spec
30
30
  test/distro_test/specs/T005.spec
31
+ test/distro_test/specs/T006.spec
31
32
  test/distro_test/specs/include.scenario
32
33
  test/distro_test/specs/no_title.spec
33
34
  test/distro_test/specs/sample.spec
@@ -180,6 +180,10 @@ module Rutema
180
180
  return "no command associated" unless @attributes[:cmd]
181
181
  return @attributes[:cmd].error
182
182
  end
183
+ def ignore?
184
+ return false unless @attributes[:ignore]
185
+ return @attributes[:ignore]
186
+ end
183
187
  def exec_time
184
188
  return 0 unless @attributes[:cmd]
185
189
  return @attributes[:cmd].exec_time
@@ -188,6 +192,9 @@ module Rutema
188
192
  return :warning unless @attributes[:cmd]
189
193
  return @attributes[:cmd].status
190
194
  end
195
+ def status= st
196
+ @attributes[:cmd].status=st if @attributes[:cmd]
197
+ end
191
198
  def run
192
199
  return not_executed unless @attributes[:cmd]
193
200
  return @attributes[:cmd].run
@@ -11,7 +11,7 @@ module Rutema
11
11
  module Version
12
12
  MAJOR=1
13
13
  MINOR=0
14
- TINY=3
14
+ TINY=4
15
15
  STRING=[ MAJOR, MINOR, TINY ].join( "." )
16
16
  end
17
17
  #The Elements module provides the namespace for the various modules adding parser functionality
@@ -194,6 +194,7 @@ module Rutema
194
194
  xmldoc=REXML::Document.new( xmltxt )
195
195
  #any step element
196
196
  step=Rutema::TestStep.new()
197
+ step.ignore=false
197
198
  xmldoc.root.attributes.each do |attr,value|
198
199
  add_attribute(step,attr,value)
199
200
  end
@@ -473,8 +474,6 @@ module Rutema
473
474
  #Returns the result of the run as a Patir::CommandSequenceStatus
474
475
  def run name,scenario
475
476
  @logger.debug("Starting run for #{name} with #{scenario.inspect}")
476
- @states[name]=Patir::CommandSequenceStatus.new(name,scenario.steps)
477
- @states[name].sequence_id="#{@number_of_runs}s"
478
477
  #if setup /teardown is defined we need to execute them before and after
479
478
  if @setup
480
479
  @logger.info("Setup for #{name}")
@@ -485,11 +484,13 @@ module Rutema
485
484
  if @states["#{name}_setup"].success?
486
485
  @logger.info("Scenario for #{name}")
487
486
  @states[name]=run_scenario(name,scenario)
487
+ @states[name].sequence_id="#{@number_of_runs}"
488
488
  end
489
489
  end
490
490
  else
491
491
  @logger.info("Scenario for #{name}")
492
492
  @states[name]=run_scenario(name,scenario)
493
+ @states[name].sequence_id="#{@number_of_runs}"
493
494
  end
494
495
  if @teardown
495
496
  #always execute teardown
@@ -517,7 +518,7 @@ module Rutema
517
518
  def success?
518
519
  @success=true
519
520
  @states.each do |k,v|
520
- @success&=v.success?
521
+ @success&=(v.status!=:error)
521
522
  end
522
523
  return @success
523
524
  end
@@ -525,11 +526,12 @@ module Rutema
525
526
  def run_scenario name,scenario
526
527
  state=Patir::CommandSequenceStatus.new(name,scenario.steps)
527
528
  begin
528
- if scenario.attended? && !self.attended?
529
+ attention_needed=scenario.attended?
530
+ if attention_needed && !self.attended?
529
531
  @logger.warn("Attended scenario cannot be run in unattended mode")
530
532
  state.status=:warning
531
533
  else
532
- if scenario.attended?
534
+ if attention_needed
533
535
  state.strategy=:attended
534
536
  else
535
537
  state.strategy=:unattended
@@ -541,7 +543,7 @@ module Rutema
541
543
  else
542
544
  stps.each do |s|
543
545
  state.step=run_step(s)
544
- break if !state.success?
546
+ break if :error==state.status
545
547
  end
546
548
  end
547
549
  end
@@ -569,7 +571,14 @@ module Rutema
569
571
  msg<<"\n#{step.cmd.error}" unless step.cmd.error.empty?
570
572
  end
571
573
  if step.status==:error
572
- @logger.error(msg)
574
+ if step.ignore?
575
+ @logger.warn("Step failed but result is being ignored!")
576
+ @logger.warn(msg)
577
+ step.status=:success
578
+
579
+ else
580
+ @logger.error(msg)
581
+ end
573
582
  else
574
583
  @logger.info(msg)
575
584
  end
@@ -9,5 +9,6 @@ configuration.tests=[
9
9
  "../specs/T002.spec",
10
10
  "../specs/T003.spec",
11
11
  "../specs/T004.spec",
12
- "../specs/T005.spec"
12
+ "../specs/T005.spec",
13
+ "../specs/T006.spec"
13
14
  ]
@@ -5,7 +5,8 @@ configuration.tests=[
5
5
  "../specs/T002.spec",
6
6
  "../specs/T003.spec",
7
7
  "../specs/T004.spec",
8
- "../specs/T005.spec"
8
+ "../specs/T005.spec",
9
+ "../specs/T006.spec"
9
10
  ]
10
11
  configuration.tool={:name=>"test",:path=>".",:configuration=>{:key=>"value"}}
11
12
  configuration.path={:name=>"test",:path=>"."}
@@ -5,5 +5,6 @@ configuration.tests=[
5
5
  "../specs/T002.spec",
6
6
  "../specs/T003.spec",
7
7
  "../specs/T004.spec",
8
- "../specs/T005.spec"
8
+ "../specs/T005.spec",
9
+ "../specs/T006.spec"
9
10
  ]
@@ -4,5 +4,6 @@ configuration.tests=[
4
4
  "../specs/T002.spec",
5
5
  "../specs/T003.spec",
6
6
  "../specs/T004.spec",
7
- "../specs/T005.spec"
7
+ "../specs/T005.spec",
8
+ "../specs/T006.spec"
8
9
  ]
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <specification name="T006">
3
+ <title>T006</title>
4
+ <description>A command test</description>
5
+ <scenario>
6
+ <command cmd="surely_it_will_fail" ignore="true"/>
7
+ <echo text="cool"/>
8
+ </scenario>
9
+ </specification>
@@ -3,12 +3,13 @@ require 'test/unit'
3
3
  require 'ostruct'
4
4
  require 'rubygems'
5
5
  require 'patir/command'
6
+ require 'mocha'
6
7
 
7
8
  #$DEBUG=true
8
9
  module TestRutema
9
10
  require 'rutema/system'
10
11
  class TestBaseXMlParser<Test::Unit::TestCase
11
- SAMPLE_SPEC=<<EOT
12
+ SAMPLE_SPEC=<<-EOT
12
13
  <specification name="sample">
13
14
  <title>Title</title>
14
15
  <description>Description</description>
@@ -17,8 +18,8 @@ module TestRutema
17
18
  <another_step script="script"/>
18
19
  </scenario>
19
20
  </specification>
20
- EOT
21
- INCLUDE_SPEC=<<EOT
21
+ EOT
22
+ INCLUDE_SPEC=<<-EOT
22
23
  <specification name="include">
23
24
  <title>Title</title>
24
25
  <description>Description</description>
@@ -27,8 +28,8 @@ EOT
27
28
  <include_scenario file="#{File.expand_path(File.dirname(__FILE__))}/distro_test/specs/include.scenario"/>
28
29
  </scenario>
29
30
  </specification>
30
- EOT
31
- BAD_INCLUDE_SPEC=<<EOT
31
+ EOT
32
+ BAD_INCLUDE_SPEC=<<-EOT
32
33
  <specification name="bad_include">
33
34
  <title>Title</title>
34
35
  <description>Description</description>
@@ -36,8 +37,8 @@ EOT
36
37
  <include_scenario file=unknown.scenario"/>
37
38
  </scenario>
38
39
  </specification>
39
- EOT
40
- MISSING_INCLUDE_SPEC=<<EOT
40
+ EOT
41
+ MISSING_INCLUDE_SPEC=<<-EOT
41
42
  <specification name="bad_include">
42
43
  <title>Title</title>
43
44
  <description>Description</description>
@@ -45,8 +46,8 @@ EOT
45
46
  <include_scenario/>
46
47
  </scenario>
47
48
  </specification>
48
- EOT
49
-
49
+ EOT
50
+
50
51
  def test_parse_specification
51
52
  parser=Rutema::BaseXMLParser.new({})
52
53
  specification=parser.parse_specification(SAMPLE_SPEC)
@@ -62,7 +63,7 @@ EOT
62
63
  assert_raise(Rutema::ParserError) { parser.parse_specification("") }
63
64
  assert_raise(Rutema::ParserError) { parser.parse_specification("missing.spec") }
64
65
  end
65
-
66
+
66
67
  def test_include
67
68
  parser=Rutema::BaseXMLParser.new({})
68
69
  specification=parser.parse_specification(INCLUDE_SPEC)
@@ -71,11 +72,11 @@ EOT
71
72
  assert_raise(Rutema::ParserError) { parser.parse_specification(BAD_INCLUDE_SPEC) }
72
73
  assert_raise(Rutema::ParserError) { parser.parse_specification(MISSING_INCLUDE_SPEC) }
73
74
  end
74
-
75
+
75
76
  end
76
-
77
+
77
78
  class TestExtensibleXMlParser<Test::Unit::TestCase
78
- SAMPLE_SPEC=<<EOT
79
+ SAMPLE_SPEC=<<-EOT
79
80
  <specification name="sample">
80
81
  <title>Title</title>
81
82
  <description>Description</description>
@@ -84,7 +85,7 @@ EOT
84
85
  <another_step script="script"/>
85
86
  </scenario>
86
87
  </specification>
87
- EOT
88
+ EOT
88
89
  def test_parse_specification
89
90
  parser=Rutema::ExtensibleXMLParser.new({})
90
91
  assert_nil(parser.configuration)
@@ -92,7 +93,7 @@ EOT
92
93
  end
93
94
  end
94
95
  class TestMinimalXMlParser<Test::Unit::TestCase
95
- SAMPLE_SPEC=<<EOT
96
+ SAMPLE_SPEC=<<-EOT
96
97
  <specification name="sample">
97
98
  <title>Title</title>
98
99
  <description>Description</description>
@@ -101,7 +102,7 @@ EOT
101
102
  <command cmd="l"/>
102
103
  </scenario>
103
104
  </specification>
104
- EOT
105
+ EOT
105
106
  def test_parse_specification
106
107
  parser=Rutema::MinimalXMLParser.new({})
107
108
  assert_nothing_raised() { @specification=parser.parse_specification(SAMPLE_SPEC) }
@@ -168,7 +169,7 @@ EOT
168
169
  state2=runner.run("test2",scenario)
169
170
  assert_equal(2, runner.states.size)
170
171
  end
171
-
172
+
172
173
  def test_run_exceptions
173
174
  runner=Rutema::Runner.new
174
175
  scenario=Rutema::TestScenario.new
@@ -187,6 +188,26 @@ EOT
187
188
  runner.reset
188
189
  assert(runner.states.empty?)
189
190
  end
191
+
192
+ def test_ignore
193
+ step=OpenStruct.new("status"=>:not_executed)
194
+ step.stubs(:number).returns(1)
195
+ step.stubs(:name).returns("mock")
196
+ step.stubs(:step_type).returns("mock")
197
+ step.stubs(:output).returns("mock")
198
+ step.stubs(:error).returns("")
199
+ step.stubs(:strategy).returns(:attended)
200
+ step.stubs(:exec_time).returns(12)
201
+ step.stubs(:has_cmd?).returns(false)
202
+ step.expects(:ignore?).returns(true)
203
+ step.expects(:status).times(5).returns(:not_executed).then.returns(:not_executed).then.returns(:error).then.returns(:warning).then.returns(:warning)
204
+ scenario=Rutema::TestScenario.new
205
+ scenario.expects(:attended?).returns(false)
206
+ scenario.stubs(:steps).returns([step])
207
+ runner=Rutema::Runner.new
208
+ runner.run("ignore",scenario)
209
+ assert(runner.success?,"run is not a success")
210
+ end
190
211
  end
191
212
 
192
213
  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: 1.0.3
4
+ version: 1.0.4
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-11-05 00:00:00 +01:00
12
+ date: 2008-11-07 00:00:00 +01:00
13
13
  default_executable: rutemax
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -125,6 +125,7 @@ files:
125
125
  - test/distro_test/specs/T003.spec
126
126
  - test/distro_test/specs/T004.spec
127
127
  - test/distro_test/specs/T005.spec
128
+ - test/distro_test/specs/T006.spec
128
129
  - test/distro_test/specs/include.scenario
129
130
  - test/distro_test/specs/no_title.spec
130
131
  - test/distro_test/specs/sample.spec