rutema 1.1.3 → 1.2.0

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.
Files changed (51) hide show
  1. data/.gemtest +0 -0
  2. data/History.txt +5 -0
  3. data/Manifest.txt +28 -23
  4. data/README.md +91 -0
  5. data/README.txt +2 -10
  6. data/Rakefile +6 -9
  7. data/bin/rutema +9 -0
  8. data/bin/rutemax +2 -0
  9. data/lib/rutema/configuration.rb +7 -8
  10. data/lib/rutema/elements/minimal.rb +45 -0
  11. data/lib/rutema/gems.rb +3 -3
  12. data/lib/rutema/models/activerecord.rb +164 -0
  13. data/lib/rutema/models/base.rb +5 -0
  14. data/lib/rutema/{specification.rb → objectmodel.rb} +4 -10
  15. data/lib/rutema/parsers/base.rb +29 -0
  16. data/lib/rutema/parsers/xml.rb +186 -0
  17. data/lib/rutema/reporters/activerecord.rb +9 -18
  18. data/lib/rutema/{reporter.rb → reporters/base.rb} +3 -7
  19. data/lib/rutema/reporters/email.rb +2 -5
  20. data/lib/rutema/reporters/text.rb +2 -2
  21. data/lib/rutema/reporters/yaml.rb +1 -2
  22. data/lib/rutema/runners/default.rb +157 -0
  23. data/lib/rutema/runners/step.rb +23 -0
  24. data/lib/rutema/system.rb +15 -420
  25. data/test/distro_test/config/full.rutema +2 -0
  26. data/test/distro_test/specs/check.spec +8 -0
  27. data/test/distro_test/specs/duplicate_name.spec +8 -0
  28. data/test/distro_test/specs/fail.spec +9 -0
  29. data/test/distro_test/specs/setup.spec +8 -0
  30. data/test/distro_test/specs/teardown.spec +8 -0
  31. data/test/rutema.rutema +1 -1
  32. data/test/rutema.spec +5 -5
  33. data/test/test_activerecord.rb +0 -0
  34. data/test/test_configuration.rb +7 -9
  35. data/test/test_couchdb.rb +14 -0
  36. data/test/{test_specification.rb → test_objectmodel.rb} +8 -11
  37. data/test/test_parsers.rb +136 -0
  38. data/test/test_rake.rb +2 -3
  39. data/test/{test_reporter.rb → test_reporters.rb} +0 -0
  40. data/test/test_runners.rb +72 -0
  41. data/test/test_system.rb +3 -166
  42. metadata +57 -62
  43. data/bin/rutema_upgrader +0 -81
  44. data/distro_test.sh +0 -6
  45. data/lib/rutema/model.rb +0 -231
  46. data/lib/rutema/reporters/couchdb.rb +0 -62
  47. data/lib/rutema/reporters/standard_reporters.rb +0 -7
  48. data/selftest.sh +0 -2
  49. data/test/data/sample09.db +0 -0
  50. data/test/migration.spec +0 -9
  51. data/test/test_model.rb +0 -62
@@ -1,3 +1,5 @@
1
+ require 'rutema/parsers/xml'
2
+ require 'rutema/reporters/activerecord'
1
3
  configuration.parser={:class=>Rutema::MinimalXMLParser}
2
4
  configuration.reporter={:class=>Rutema::ActiveRecordReporter, :db=>{:adapter=>"sqlite3",:database=>"sample.db"}}
3
5
  configuration.tests=[
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <specification name="check">
3
+ <title>Check specification</title>
4
+ <description>Runs once at the beginning</description>
5
+ <scenario>
6
+ <echo text="Just checking"/>
7
+ </scenario>
8
+ </specification>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <specification name="sample">
3
+ <title>Duplicate name specification</title>
4
+ <description>Check for parser errors</description>
5
+ <scenario>
6
+ <echo text="Hello testing world"/>
7
+ </scenario>
8
+ </specification>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <specification name="fail">
3
+ <title>Failing specification</title>
4
+ <description>This will fail</description>
5
+ <scenario>
6
+ <echo text="About to fail"/>
7
+ <command cmd="cd blibliki"/>
8
+ </scenario>
9
+ </specification>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <specification name="setup">
3
+ <title>Setup specification</title>
4
+ <description>Runs before every test</description>
5
+ <scenario>
6
+ <echo text="Setting up"/>
7
+ </scenario>
8
+ </specification>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <specification name="teardown">
3
+ <title>Teardown specification</title>
4
+ <description>Runs after every test</description>
5
+ <scenario>
6
+ <echo text="Tearing down"/>
7
+ </scenario>
8
+ </specification>
data/test/rutema.rutema CHANGED
@@ -1,3 +1,3 @@
1
1
  configuration.parser={:class=>Rutema::MinimalXMLParser}
2
2
  configuration.reporter={:class=>Rutema::ActiveRecordReporter, :db=>{:adapter=>"sqlite3",:database=>"rutema.db"}}
3
- configuration.tests=["rutema.spec","migration.spec"]
3
+ configuration.tests=["rutema.spec"]
data/test/rutema.spec CHANGED
@@ -1,10 +1,10 @@
1
1
  <specification name="TR001">
2
2
  <title>Rutema self hosting test</title>
3
- <description>Test that rutemax is usable as a step in a specification using the distro test example</description>
3
+ <description>Test that rutema is usable as a step in a specification using the distro test example</description>
4
4
  <scenario>
5
- <command cmd="rutemax -c distro_test/config/minimal.rutema"/>
6
- <command cmd="rutemax -c distro_test/config/database.rutema"/>
7
- <command cmd="rutemax -c distro_test/config/database.rutema distro_test/specs/T001.spec"/>
8
- <command cmd="rutemax -c distro_test/config/full.rutema"/>
5
+ <command cmd="rutema -c distro_test/config/minimal.rutema"/>
6
+ <command cmd="rutema -c distro_test/config/database.rutema"/>
7
+ <command cmd="rutema -c distro_test/config/database.rutema distro_test/specs/T001.spec"/>
8
+ <command cmd="rutema -c distro_test/config/full.rutema"/>
9
9
  </scenario>
10
10
  </specification>
Binary file
@@ -1,13 +1,11 @@
1
- $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
-
1
+ $:.unshift File.join(File.dirname(__FILE__),"..")
3
2
  require 'test/unit'
4
3
  require 'rubygems'
5
- require 'rutema/gems'
4
+ require 'patir/configuration'
5
+ require 'lib/rutema/configuration'
6
6
  #$DEBUG=true
7
7
  module TestRutema
8
- require 'rutema/system'
9
-
10
- class TestRutemaXConfigurator<Test::Unit::TestCase
8
+ class TestRutemaConfigurator<Test::Unit::TestCase
11
9
  def setup
12
10
  @prev_dir=Dir.pwd
13
11
  Dir.chdir(File.dirname(__FILE__))
@@ -15,10 +13,10 @@ module TestRutema
15
13
  def teardown
16
14
  Dir.chdir(@prev_dir)
17
15
  end
18
- def test_rutemax_configuration
16
+ def test_rutema_configuration
19
17
  cfg=nil
20
18
  #load the valid configuration
21
- assert_nothing_raised() { cfg=Rutema::RutemaXConfigurator.new("distro_test/config/full.rutema").configuration}
19
+ assert_nothing_raised() { cfg=Rutema::RutemaConfigurator.new("distro_test/config/full.rutema").configuration}
22
20
  assert_not_nil(cfg.parser)
23
21
  assert_not_nil(cfg.reporters)
24
22
  assert_equal(1, cfg.reporters.size)
@@ -36,7 +34,7 @@ module TestRutema
36
34
  end
37
35
 
38
36
  def test_specification_paths
39
- cfg=Rutema::RutemaXConfigurator.new("distro_test/config/full.rutema").configuration
37
+ cfg=Rutema::RutemaConfigurator.new("distro_test/config/full.rutema").configuration
40
38
  assert_not_nil(cfg.tests)
41
39
  end
42
40
  end
data/test/test_couchdb.rb CHANGED
@@ -16,6 +16,20 @@ module TestRutema
16
16
  end
17
17
 
18
18
  class TestCouchDBModel<Test::Unit::TestCase
19
+ def setup
20
+ @db=CouchRest.database!("http://localhost:5984/rutema_test")
21
+ end
22
+
23
+ def test_couchdb_model
24
+ run=Rutema::CouchDB::Run.new
25
+ run.database=@db
26
+ run.context="context"
27
+ run.scenarios=["1","2","#{self.object_id}"]
28
+ assert_nothing_raised() { run.save }
29
+
30
+ r=Rutema::CouchDB::Run.get(run.slug)
31
+ assert_equal(run.slug, r.slug)
32
+ end
19
33
  end
20
34
 
21
35
  class TestCouchDBReporter<Test::Unit::TestCase
@@ -1,9 +1,8 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
2
  require 'test/unit'
3
3
  require 'rubygems'
4
- require 'rutema/gems'
4
+ require 'rutema/objectmodel'
5
5
  module TestRutema
6
- require 'rutema/specification'
7
6
  class DummyCommand
8
7
  include Patir::Command
9
8
  def initialize
@@ -11,9 +10,6 @@ module TestRutema
11
10
  @output="output"
12
11
  @error="error"
13
12
  end
14
- def to_s
15
- return ""
16
- end
17
13
  end
18
14
  class Dummy
19
15
  include Rutema::SpecificationElement
@@ -23,26 +19,27 @@ module TestRutema
23
19
  step=Rutema::TestStep.new("test step",DummyCommand.new())
24
20
  assert(!step.attended?, "attended?")
25
21
  assert_not_equal("dummy", step.name)
26
- assert_equal("step - ", step.name)
22
+ assert(/step - .*DummyCommand.*/=~step.name)
27
23
  assert_equal("output", step.output)
28
24
  assert_equal("error", step.error)
29
25
  assert_equal(:not_executed, step.status)
30
26
  assert_nothing_raised() { step.run }
31
- assert_nothing_raised() { step.run("context") }
32
27
  assert_equal(:success, step.status)
33
28
  assert_nothing_raised() { step.reset }
34
29
  assert_equal(:not_executed, step.status)
35
30
  assert_equal("", step.output)
31
+ assert(/0 - step - .*DummyCommand.*- not_executed/=~step.to_s)
36
32
  end
37
33
  end
38
34
  class TestSpecification<Test::Unit::TestCase
39
35
  def test_new
40
- spec=Rutema::TestSpecification.new
41
- assert_equal("", spec.name)
42
- assert_equal("", spec.title)
43
- assert_equal("", spec.description)
36
+ spec=Rutema::TestSpecification.new(:name=>"name",:title=>"title",:description=>"description")
37
+ assert_equal("name", spec.name)
38
+ assert_equal("title", spec.title)
39
+ assert_equal("description", spec.description)
44
40
  assert_not_nil(spec.scenario)
45
41
  assert(spec.requirements.empty?)
42
+ assert_equal("name - title", spec.to_s)
46
43
  end
47
44
  end
48
45
  class TestScenario<Test::Unit::TestCase
@@ -0,0 +1,136 @@
1
+ $:.unshift File.join(File.dirname(__FILE__),'..','lib')
2
+ require 'test/unit'
3
+ require 'ostruct'
4
+
5
+ require 'rubygems'
6
+ require 'patir/command'
7
+ require 'mocha'
8
+
9
+ require 'rutema/parsers/base'
10
+ require 'rutema/parsers/xml'
11
+
12
+ #$DEBUG=true
13
+ module TestRutema
14
+ class TestSpecificationParser<Test::Unit::TestCase
15
+ def test_specification_parser
16
+ parser=nil
17
+ assert_nothing_raised() { parser=Rutema::SpecificationParser.new({}) }
18
+ assert_not_nil(parser)
19
+ assert(!parser.configuration.empty?)
20
+ assert_raise(Rutema::ParserError) { parser.parse_specification("foo") }
21
+ end
22
+ end
23
+ class TestBaseXMlParser<Test::Unit::TestCase
24
+ SAMPLE_SPEC=<<-EOT
25
+ <specification name="sample">
26
+ <title>Title</title>
27
+ <description>Description</description>
28
+ <scenario>
29
+ <step/>
30
+ <another_step script="script"/>
31
+ </scenario>
32
+ </specification>
33
+ EOT
34
+ INCLUDE_SPEC=<<-EOT
35
+ <specification name="include">
36
+ <title>Title</title>
37
+ <description>Description</description>
38
+ <scenario>
39
+ <step/>
40
+ <include_scenario file="#{File.expand_path(File.dirname(__FILE__))}/distro_test/specs/include.scenario"/>
41
+ </scenario>
42
+ </specification>
43
+ EOT
44
+ BAD_INCLUDE_SPEC=<<-EOT
45
+ <specification name="bad_include">
46
+ <title>Title</title>
47
+ <description>Description</description>
48
+ <scenario>
49
+ <include_scenario file=unknown.scenario"/>
50
+ </scenario>
51
+ </specification>
52
+ EOT
53
+ MISSING_INCLUDE_SPEC=<<-EOT
54
+ <specification name="bad_include">
55
+ <title>Title</title>
56
+ <description>Description</description>
57
+ <scenario>
58
+ <include_scenario/>
59
+ </scenario>
60
+ </specification>
61
+ EOT
62
+
63
+ def test_parse_specification
64
+ parser=Rutema::BaseXMLParser.new({})
65
+ specification=parser.parse_specification(SAMPLE_SPEC)
66
+ assert_equal("sample",specification.name)
67
+ assert_equal("Description", specification.description)
68
+ assert_equal("Title", specification.title)
69
+ assert(specification.scenario)
70
+ assert_equal(2, specification.scenario.steps.size)
71
+ assert_equal(1, specification.scenario.steps[0].number)
72
+ assert_equal("another_step", specification.scenario.steps[1].step_type)
73
+ assert_equal("script", specification.scenario.steps[1].script)
74
+ assert_equal(2, specification.scenario.steps[1].number)
75
+ assert_raise(Rutema::ParserError) { parser.parse_specification("") }
76
+ assert_raise(Rutema::ParserError) { parser.parse_specification("missing.spec") }
77
+ end
78
+
79
+ def test_include
80
+ parser=Rutema::BaseXMLParser.new({})
81
+ specification=parser.parse_specification(INCLUDE_SPEC)
82
+ assert_equal(3, specification.scenario.steps.size)
83
+ assert(specification.scenario.steps[2].has_included_in?)
84
+ assert_raise(Rutema::ParserError) { parser.parse_specification(BAD_INCLUDE_SPEC) }
85
+ assert_raise(Rutema::ParserError) { parser.parse_specification(MISSING_INCLUDE_SPEC) }
86
+ end
87
+
88
+ end
89
+ class TestExtensibleXMlParser<Test::Unit::TestCase
90
+ SAMPLE_SPEC=<<-EOT
91
+ <specification name="sample">
92
+ <title>Title</title>
93
+ <description>Description</description>
94
+ <scenario>
95
+ <step/>
96
+ <another_step script="script"/>
97
+ </scenario>
98
+ </specification>
99
+ EOT
100
+ def test_parse_specification
101
+ parser=Rutema::ExtensibleXMLParser.new({})
102
+ assert_not_nil(parser.configuration)
103
+ specification=nil
104
+ assert_nothing_raised() { specification=parser.parse_specification(SAMPLE_SPEC) }
105
+ assert_equal(2, specification.scenario.steps.size)
106
+ end
107
+ def test_parse_error
108
+ parser=Rutema::ExtensibleXMLParser.new({})
109
+ assert_not_nil(parser.configuration)
110
+ specification=nil
111
+ assert_raise(Rutema::ParserError) { specification=parser.parse_specification("<") }
112
+ end
113
+ end
114
+ class TestMinimalXMlParser<Test::Unit::TestCase
115
+ SAMPLE_SPEC=<<-EOT
116
+ <specification name="sample">
117
+ <title>Title</title>
118
+ <description>Description</description>
119
+ <scenario>
120
+ <echo/>
121
+ <command cmd="l"/>
122
+ </scenario>
123
+ </specification>
124
+ EOT
125
+ def test_parse_specification
126
+ parser=Rutema::MinimalXMLParser.new({})
127
+ specification=nil
128
+ assert_nothing_raised() { specification=parser.parse_specification(SAMPLE_SPEC) }
129
+ assert_not_nil(specification)
130
+ assert_equal(2, specification.scenario.steps.size)
131
+ assert_equal("Description", specification.description)
132
+ assert_equal("Title", specification.title)
133
+ assert_equal("sample", specification.name)
134
+ end
135
+ end
136
+ end
data/test/test_rake.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
- require 'rubygems'
3
- require 'rutema/gems'
4
2
  require 'test/unit'
3
+ require 'rubygems'
4
+ require 'rake'
5
5
  require 'rutema/rake'
6
6
 
7
7
  module TestRutema
@@ -14,7 +14,6 @@ module TestRutema
14
14
  assert_equal([], t.rake_task.prerequisites)
15
15
  assert_nothing_raised() { t.add_dependency("some_task") }
16
16
  assert_equal(["some_task"], t.rake_task.prerequisites)
17
-
18
17
  end
19
18
 
20
19
  def test_rake_task_block
@@ -0,0 +1,72 @@
1
+ $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
+ require 'test/unit'
3
+ require 'ostruct'
4
+
5
+ require 'rubygems'
6
+ require 'patir/command'
7
+ require 'mocha'
8
+
9
+ require 'rutema/objectmodel'
10
+ require 'rutema/runners/default'
11
+ require 'rutema/runners/step'
12
+
13
+ #$DEBUG=true
14
+ module TestRutema
15
+ class TestRunner<Test::Unit::TestCase
16
+ def test_new
17
+ runner=Rutema::Runner.new
18
+ assert(!runner.attended?)
19
+ assert_nil(runner.setup)
20
+ assert_nil(runner.teardown)
21
+ assert(runner.states.empty?)
22
+ end
23
+ def test_run
24
+ runner=Rutema::Runner.new
25
+ scenario=Rutema::TestScenario.new
26
+ state1=runner.run("test1",scenario)
27
+ state2=runner.run("test2",scenario)
28
+ assert_equal(state1, runner["test1"])
29
+ assert_equal(state2, runner["test2"])
30
+ assert_equal(2, runner.states.size)
31
+ state2=runner.run("test2",scenario)
32
+ assert_equal(2, runner.states.size)
33
+ end
34
+ def test_run_exceptions
35
+ runner=Rutema::Runner.new
36
+ scenario=Rutema::TestScenario.new
37
+ step=Rutema::TestStep.new("bad",Patir::RubyCommand.new("bad"){|cmd| raise "Bad command"})
38
+ scenario.add_step(step)
39
+ state1=:success
40
+ assert_nothing_raised() { state1=runner.run("test1",scenario) }
41
+ assert_equal(:error, state1.status)
42
+ end
43
+ def test_reset
44
+ runner=Rutema::Runner.new
45
+ scenario=Rutema::TestScenario.new
46
+ state1=runner.run("test1",scenario)
47
+ state2=runner.run("test2",scenario)
48
+ assert_equal(2, runner.states.size)
49
+ runner.reset
50
+ assert(runner.states.empty?)
51
+ end
52
+ def test_ignore
53
+ step=OpenStruct.new("status"=>:not_executed)
54
+ step.stubs(:number).returns(1)
55
+ step.stubs(:name).returns("mock")
56
+ step.stubs(:step_type).returns("mock")
57
+ step.stubs(:output).returns("mock")
58
+ step.stubs(:error).returns("")
59
+ step.stubs(:strategy).returns(:attended)
60
+ step.stubs(:exec_time).returns(12)
61
+ step.stubs(:has_cmd?).returns(false)
62
+ step.expects(:ignore?).returns(true)
63
+ step.expects(:status).times(6).returns(:not_executed).then.returns(:not_executed).then.returns(:error).then.returns(:warning).then.returns(:warning).then.returns(:warning)
64
+ scenario=Rutema::TestScenario.new
65
+ scenario.expects(:attended?).returns(false)
66
+ scenario.stubs(:steps).returns([step])
67
+ runner=Rutema::Runner.new
68
+ runner.run("ignore",scenario)
69
+ assert(runner.success?,"run is not a success")
70
+ end
71
+ end
72
+ end
data/test/test_system.rb CHANGED
@@ -1,114 +1,14 @@
1
- $:.unshift File.join(File.dirname(__FILE__),"..","lib")
1
+ $:.unshift File.join(File.dirname(__FILE__),"..")
2
2
  require 'rubygems'
3
3
  require 'test/unit'
4
4
  require 'ostruct'
5
5
  require 'patir/command'
6
6
  require 'mocha'
7
+ require 'lib/rutema/system'
8
+ require 'lib/rutema/parsers/xml'
7
9
 
8
10
  #$DEBUG=true
9
11
  module TestRutema
10
- require 'rutema/system'
11
- class TestBaseXMlParser<Test::Unit::TestCase
12
- SAMPLE_SPEC=<<-EOT
13
- <specification name="sample">
14
- <title>Title</title>
15
- <description>Description</description>
16
- <scenario>
17
- <step/>
18
- <another_step script="script"/>
19
- </scenario>
20
- </specification>
21
- EOT
22
- INCLUDE_SPEC=<<-EOT
23
- <specification name="include">
24
- <title>Title</title>
25
- <description>Description</description>
26
- <scenario>
27
- <step/>
28
- <include_scenario file="#{File.expand_path(File.dirname(__FILE__))}/distro_test/specs/include.scenario"/>
29
- </scenario>
30
- </specification>
31
- EOT
32
- BAD_INCLUDE_SPEC=<<-EOT
33
- <specification name="bad_include">
34
- <title>Title</title>
35
- <description>Description</description>
36
- <scenario>
37
- <include_scenario file=unknown.scenario"/>
38
- </scenario>
39
- </specification>
40
- EOT
41
- MISSING_INCLUDE_SPEC=<<-EOT
42
- <specification name="bad_include">
43
- <title>Title</title>
44
- <description>Description</description>
45
- <scenario>
46
- <include_scenario/>
47
- </scenario>
48
- </specification>
49
- EOT
50
-
51
- def test_parse_specification
52
- parser=Rutema::BaseXMLParser.new({})
53
- specification=parser.parse_specification(SAMPLE_SPEC)
54
- assert_equal("sample",specification.name)
55
- assert_equal("Description", specification.description)
56
- assert_equal("Title", specification.title)
57
- assert(specification.scenario)
58
- assert_equal(2, specification.scenario.steps.size)
59
- assert_equal(1, specification.scenario.steps[0].number)
60
- assert_equal("another_step", specification.scenario.steps[1].step_type)
61
- assert_equal("script", specification.scenario.steps[1].script)
62
- assert_equal(2, specification.scenario.steps[1].number)
63
- assert_raise(Rutema::ParserError) { parser.parse_specification("") }
64
- assert_raise(Rutema::ParserError) { parser.parse_specification("missing.spec") }
65
- end
66
-
67
- def test_include
68
- parser=Rutema::BaseXMLParser.new({})
69
- specification=parser.parse_specification(INCLUDE_SPEC)
70
- assert_equal(3, specification.scenario.steps.size)
71
- assert(specification.scenario.steps[2].has_included_in?)
72
- assert_raise(Rutema::ParserError) { parser.parse_specification(BAD_INCLUDE_SPEC) }
73
- assert_raise(Rutema::ParserError) { parser.parse_specification(MISSING_INCLUDE_SPEC) }
74
- end
75
-
76
- end
77
-
78
- class TestExtensibleXMlParser<Test::Unit::TestCase
79
- SAMPLE_SPEC=<<-EOT
80
- <specification name="sample">
81
- <title>Title</title>
82
- <description>Description</description>
83
- <scenario>
84
- <step/>
85
- <another_step script="script"/>
86
- </scenario>
87
- </specification>
88
- EOT
89
- def test_parse_specification
90
- parser=Rutema::ExtensibleXMLParser.new({})
91
- assert_nil(parser.configuration)
92
- assert_nothing_raised() { specification=parser.parse_specification(SAMPLE_SPEC) }
93
- end
94
- end
95
- class TestMinimalXMlParser<Test::Unit::TestCase
96
- SAMPLE_SPEC=<<-EOT
97
- <specification name="sample">
98
- <title>Title</title>
99
- <description>Description</description>
100
- <scenario>
101
- <echo/>
102
- <command cmd="l"/>
103
- </scenario>
104
- </specification>
105
- EOT
106
- def test_parse_specification
107
- parser=Rutema::MinimalXMLParser.new({})
108
- assert_nothing_raised() { @specification=parser.parse_specification(SAMPLE_SPEC) }
109
- assert_equal(2, @specification.scenario.steps.size)
110
- end
111
- end
112
12
  class TestCoordinator<Test::Unit::TestCase
113
13
  def setup
114
14
  @prev_dir=Dir.pwd
@@ -145,67 +45,4 @@ module TestRutema
145
45
  puts coord.to_s if $DEBUG
146
46
  end
147
47
  end
148
-
149
- class TestRunner<Test::Unit::TestCase
150
- def test_new
151
- runner=Rutema::Runner.new
152
- assert(!runner.attended?)
153
- assert_nil(runner.setup)
154
- assert_nil(runner.teardown)
155
- assert(runner.states.empty?)
156
- end
157
-
158
- def test_run
159
- runner=Rutema::Runner.new
160
- scenario=Rutema::TestScenario.new
161
- state1=runner.run("test1",scenario)
162
- state2=runner.run("test2",scenario)
163
- assert_equal(state1, runner["test1"])
164
- assert_equal(state2, runner["test2"])
165
- assert_equal(2, runner.states.size)
166
- state2=runner.run("test2",scenario)
167
- assert_equal(2, runner.states.size)
168
- end
169
-
170
- def test_run_exceptions
171
- runner=Rutema::Runner.new
172
- scenario=Rutema::TestScenario.new
173
- step=Rutema::TestStep.new("bad",Patir::RubyCommand.new("bad"){|cmd| raise "Bad command"})
174
- scenario.add_step(step)
175
- state1=:success
176
- assert_nothing_raised() { state1=runner.run("test1",scenario) }
177
- assert_equal(:error, state1.status)
178
- end
179
- def test_reset
180
- runner=Rutema::Runner.new
181
- scenario=Rutema::TestScenario.new
182
- state1=runner.run("test1",scenario)
183
- state2=runner.run("test2",scenario)
184
- assert_equal(2, runner.states.size)
185
- runner.reset
186
- assert(runner.states.empty?)
187
- end
188
-
189
- def test_ignore
190
- $DEBUG=true
191
- step=OpenStruct.new("status"=>:not_executed)
192
- step.stubs(:number).returns(1)
193
- step.stubs(:name).returns("mock")
194
- step.stubs(:step_type).returns("mock")
195
- step.stubs(:output).returns("mock")
196
- step.stubs(:error).returns("")
197
- step.stubs(:strategy).returns(:attended)
198
- step.stubs(:exec_time).returns(12)
199
- step.stubs(:has_cmd?).returns(false)
200
- step.expects(:ignore?).returns(true)
201
- step.expects(:status).times(6).returns(:not_executed).then.returns(:not_executed).then.returns(:error).then.returns(:warning).then.returns(:warning)
202
- scenario=Rutema::TestScenario.new
203
- scenario.expects(:attended?).returns(false)
204
- scenario.stubs(:steps).returns([step])
205
- runner=Rutema::Runner.new
206
- runner.run("ignore",scenario)
207
- assert(runner.success?,"run is not a success")
208
- end
209
- end
210
-
211
48
  end