jstorimer-deep-test 1.4.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. data/.gitignore +1 -0
  2. data/README.rdoc +41 -70
  3. data/Rakefile +47 -119
  4. data/TODO +2 -2
  5. data/VERSION +1 -1
  6. data/infrastructure/dynamic_teardown.rb +22 -0
  7. data/{test → infrastructure}/fake_deadlock_error.rb +0 -0
  8. data/infrastructure/load.rb +11 -0
  9. data/infrastructure/test_central_command.rb +15 -0
  10. data/infrastructure/test_exception.rb +7 -0
  11. data/{test → infrastructure}/test_factory.rb +0 -0
  12. data/infrastructure/test_logger.rb +11 -0
  13. data/infrastructure/test_operator.rb +15 -0
  14. data/infrastructure/test_result.rb +15 -0
  15. data/infrastructure/thread_agent.rb +21 -0
  16. data/infrastructure/timewarp/Rakefile +14 -0
  17. data/infrastructure/timewarp/lib/timewarp.rb +21 -0
  18. data/infrastructure/timewarp/test/timewarp_test.rb +45 -0
  19. data/lib/deep_test.rb +28 -40
  20. data/lib/deep_test/agent.rb +108 -0
  21. data/lib/deep_test/central_command.rb +165 -0
  22. data/lib/deep_test/cpu_info.rb +22 -0
  23. data/lib/deep_test/database/mysql_setup_listener.rb +11 -12
  24. data/lib/deep_test/database/setup_listener.rb +23 -23
  25. data/lib/deep_test/demon.rb +25 -0
  26. data/lib/deep_test/distributed/beachhead.rb +104 -0
  27. data/lib/deep_test/distributed/dispatch_controller.rb +17 -10
  28. data/lib/deep_test/distributed/establish_beachhead.rb +19 -0
  29. data/lib/deep_test/distributed/landing_fleet.rb +30 -0
  30. data/lib/deep_test/distributed/landing_ship.rb +60 -0
  31. data/lib/deep_test/distributed/remote_deployment.rb +56 -0
  32. data/lib/deep_test/distributed/rsync.rb +25 -12
  33. data/lib/deep_test/distributed/shell_environment.rb +50 -0
  34. data/lib/deep_test/distributed/ssh_client_connection_info.rb +14 -0
  35. data/lib/deep_test/failure_message.rb +19 -0
  36. data/lib/deep_test/lib_root.rb +4 -0
  37. data/lib/deep_test/listener_list.rb +1 -1
  38. data/lib/deep_test/local_deployment.rb +46 -0
  39. data/lib/deep_test/logger.rb +17 -2
  40. data/lib/deep_test/main.rb +41 -0
  41. data/lib/deep_test/marshallable_exception_wrapper.rb +4 -4
  42. data/lib/deep_test/metrics/data.rb +34 -0
  43. data/lib/deep_test/metrics/measurement.rb +39 -0
  44. data/lib/deep_test/{null_worker_listener.rb → null_listener.rb} +14 -14
  45. data/lib/deep_test/options.rb +41 -56
  46. data/lib/deep_test/proxy_io.rb +77 -0
  47. data/lib/deep_test/rake_tasks.rb +3 -1
  48. data/lib/deep_test/result_reader.rb +10 -6
  49. data/lib/deep_test/rspec_detector.rb +1 -1
  50. data/lib/deep_test/spec.rb +5 -1
  51. data/lib/deep_test/spec/extensions/example_methods.rb +7 -1
  52. data/lib/deep_test/spec/extensions/spec_task.rb +3 -2
  53. data/lib/deep_test/spec/runner.rb +32 -17
  54. data/lib/deep_test/spec/work_result.rb +2 -0
  55. data/lib/deep_test/test/run_test_suite.rb +5 -0
  56. data/lib/deep_test/test/runner.rb +2 -2
  57. data/lib/deep_test/test/supervised_test_suite.rb +9 -10
  58. data/lib/deep_test/test/work_result.rb +1 -0
  59. data/lib/deep_test/test_task.rb +1 -1
  60. data/lib/deep_test/ui/console.rb +9 -11
  61. data/lib/deep_test/warlock.rb +37 -25
  62. data/lib/telegraph.rb +29 -0
  63. data/lib/telegraph/ack_sequence.rb +14 -0
  64. data/lib/telegraph/logging.rb +20 -0
  65. data/lib/telegraph/message.rb +39 -0
  66. data/lib/telegraph/operator.rb +47 -0
  67. data/lib/telegraph/switchboard.rb +57 -0
  68. data/lib/telegraph/wire.rb +73 -0
  69. data/negative_acceptance_tests/dying_spec.rb +13 -0
  70. data/negative_acceptance_tests/dying_test.rb +13 -0
  71. data/negative_acceptance_tests/failing_spec.rb +9 -0
  72. data/{test/failing.rb → negative_acceptance_tests/failing_test.rb} +3 -1
  73. data/negative_acceptance_tests/kill_agent_one_on_start_work.rb +16 -0
  74. data/negative_acceptance_tests/passing_spec.rb +10 -0
  75. data/negative_acceptance_tests/passing_test.rb +12 -0
  76. data/negative_acceptance_tests/tasks.rake +87 -0
  77. data/negative_acceptance_tests/tests.rb +60 -0
  78. data/sample_rails_project/deep_test.rb +4 -0
  79. data/sample_rails_project/lib/{foreign_host_worker_simulation_listener.rb → foreign_host_agent_simulation_listener.rb} +6 -4
  80. data/sample_rails_project/lib/tasks/deep_test.rake +13 -4
  81. data/spec/deep_test/options_spec.rb +80 -59
  82. data/spec/deep_test/spec/extensions/example_methods_spec.rb +5 -4
  83. data/spec/deep_test/spec/extensions/spec_task_spec.rb +4 -6
  84. data/spec/deep_test/spec/runner_spec.rb +59 -32
  85. data/spec/spec_helper.rb +14 -6
  86. data/test/deep_test/agent_test.rb +175 -0
  87. data/test/deep_test/central_command_test.rb +147 -0
  88. data/test/deep_test/cpu_info_test.rb +33 -0
  89. data/test/deep_test/database/mysql_setup_listener_test.rb +13 -9
  90. data/test/deep_test/demon_test.rb +23 -0
  91. data/test/deep_test/distributed/beachhead_test.rb +67 -0
  92. data/test/deep_test/distributed/dispatch_controller_test.rb +130 -177
  93. data/test/deep_test/distributed/filename_resolver_test.rb +38 -34
  94. data/test/deep_test/distributed/landing_fleet_test.rb +55 -0
  95. data/test/deep_test/distributed/landing_ship_test.rb +48 -0
  96. data/test/deep_test/distributed/remote_deployment_test.rb +134 -0
  97. data/test/deep_test/distributed/rsync_test.rb +42 -62
  98. data/test/deep_test/distributed/shell_environment_fixtures/set_bar_to_foo +1 -0
  99. data/test/deep_test/distributed/shell_environment_fixtures/set_foo_to_bar +1 -0
  100. data/test/deep_test/distributed/shell_environment_fixtures/set_foo_to_baz +1 -0
  101. data/test/deep_test/distributed/shell_environment_test.rb +108 -0
  102. data/test/deep_test/distributed/ssh_client_connection_info_test.rb +34 -0
  103. data/test/deep_test/listener_list_test.rb +17 -15
  104. data/test/deep_test/local_deployment_test.rb +19 -0
  105. data/test/deep_test/logger_test.rb +34 -7
  106. data/test/deep_test/main_test.rb +12 -0
  107. data/test/deep_test/marshallable_exception_wrapper_test.rb +31 -29
  108. data/test/deep_test/metrics/data_test.rb +22 -0
  109. data/test/deep_test/metrics/measurement_test.rb +18 -0
  110. data/test/deep_test/proxy_io_test.rb +104 -0
  111. data/test/deep_test/result_reader_test.rb +95 -95
  112. data/test/deep_test/test/extensions/error_test.rb +38 -36
  113. data/test/deep_test/test/runner_test.rb +7 -3
  114. data/test/deep_test/test/supervised_test_suite_test.rb +89 -61
  115. data/test/deep_test/test/work_result_test.rb +80 -76
  116. data/test/deep_test/test/work_unit_test.rb +53 -51
  117. data/test/deep_test/test_task_test.rb +10 -38
  118. data/test/deep_test/ui/console_test.rb +8 -4
  119. data/test/deep_test/warlock_test.rb +33 -31
  120. data/test/test_helper.rb +20 -5
  121. data/test/test_task_test.rb +60 -57
  122. metadata +94 -84
  123. data/bin/deep_test +0 -15
  124. data/jstorimer-deep-test-0.1.0.gem +0 -0
  125. data/jstorimer-deep-test.gemspec +0 -1425
  126. data/lib/deep_test/distributed/drb_client_connection_info.rb +0 -15
  127. data/lib/deep_test/distributed/master_test_server.rb +0 -52
  128. data/lib/deep_test/distributed/multi_test_server_proxy.rb +0 -44
  129. data/lib/deep_test/distributed/null_work_unit.rb +0 -12
  130. data/lib/deep_test/distributed/remote_worker_client.rb +0 -54
  131. data/lib/deep_test/distributed/remote_worker_server.rb +0 -82
  132. data/lib/deep_test/distributed/show_status.rhtml +0 -41
  133. data/lib/deep_test/distributed/test_server.rb +0 -78
  134. data/lib/deep_test/distributed/test_server_status.rb +0 -9
  135. data/lib/deep_test/distributed/test_server_workers.rb +0 -24
  136. data/lib/deep_test/distributed/throughput_runner.rb +0 -42
  137. data/lib/deep_test/distributed/throughput_statistics.rb +0 -26
  138. data/lib/deep_test/distributed/throughput_worker_client.rb +0 -19
  139. data/lib/deep_test/extensions/drb_extension.rb +0 -34
  140. data/lib/deep_test/local_workers.rb +0 -55
  141. data/lib/deep_test/metrics/gatherer.rb +0 -67
  142. data/lib/deep_test/metrics/queue_lock_wait_time_measurement.rb +0 -133
  143. data/lib/deep_test/option.rb +0 -60
  144. data/lib/deep_test/process_orchestrator.rb +0 -49
  145. data/lib/deep_test/server.rb +0 -75
  146. data/lib/deep_test/spec/extensions/reporter.rb +0 -29
  147. data/lib/deep_test/worker.rb +0 -57
  148. data/script/internal/run_test_suite.rb +0 -7
  149. data/script/public/master_test_server.rb +0 -24
  150. data/script/public/test_server.rb +0 -18
  151. data/script/public/test_throughput.rb +0 -29
  152. data/spec/deep_test/option_spec.rb +0 -33
  153. data/spec/thread_worker.rb +0 -25
  154. data/test/deep_test/distributed/drb_client_connection_info_test.rb +0 -42
  155. data/test/deep_test/distributed/master_test_server_test.rb +0 -32
  156. data/test/deep_test/distributed/multi_test_server_proxy_test.rb +0 -96
  157. data/test/deep_test/distributed/remote_worker_client_test.rb +0 -180
  158. data/test/deep_test/distributed/remote_worker_server_test.rb +0 -99
  159. data/test/deep_test/distributed/test_server_test.rb +0 -94
  160. data/test/deep_test/distributed/test_server_workers_test.rb +0 -26
  161. data/test/deep_test/distributed/throughput_runner_test.rb +0 -68
  162. data/test/deep_test/distributed/throughput_worker_client_test.rb +0 -28
  163. data/test/deep_test/local_workers_test.rb +0 -22
  164. data/test/deep_test/metrics/gatherer_test.rb +0 -66
  165. data/test/deep_test/process_orchestrator_test.rb +0 -11
  166. data/test/deep_test/server_test.rb +0 -58
  167. data/test/deep_test/worker_test.rb +0 -94
  168. data/test/failing.rake +0 -11
  169. data/test/simple_test_blackboard.rb +0 -45
  170. data/test/simple_test_blackboard_test.rb +0 -33
@@ -1,40 +1,42 @@
1
1
  require File.dirname(__FILE__) + "/../../../test_helper"
2
2
 
3
- unit_tests do
4
- test "make_exception_marshallable wraps exception in a mashallable exception" do
5
- error = Test::Unit::Error.new "test_name", Exception.new("message")
6
- error.make_exception_marshallable
7
-
8
- assert_kind_of DeepTest::MarshallableExceptionWrapper, error.exception
9
- end
10
-
11
- test "calling make_exception_marshallable twice only wraps exception once" do
12
- error = Test::Unit::Error.new "test_name", Exception.new("message")
13
- error.make_exception_marshallable
14
- error.make_exception_marshallable
15
-
16
- assert_kind_of DeepTest::MarshallableExceptionWrapper, error.exception
17
- end
18
-
19
- test "error is accessible as normal when it has not been made marshallable" do
20
- error = Test::Unit::Error.new "test_name", e = Exception.new("message")
21
- assert_equal e, error.exception
22
- end
23
-
24
- test "resolve_marshallable_exception restores the original exception" do
25
- error = Test::Unit::Error.new "test_name", Exception.new("message")
26
- error.make_exception_marshallable
27
- error.resolve_marshallable_exception
28
-
29
- assert_kind_of Exception, error.exception
30
- assert_equal 'message', error.exception.message
31
- end
32
-
33
- test "resolve_marshallable_exception does not fail when exception has not been made marshallable" do
34
- error = Test::Unit::Error.new "test_name", Exception.new("message")
35
- error.resolve_marshallable_exception
36
-
37
- assert_kind_of Exception, error.exception
38
- assert_equal 'message', error.exception.message
3
+ module DeepTest
4
+ unit_tests do
5
+ test "make_exception_marshallable wraps exception in a mashallable exception" do
6
+ error = ::Test::Unit::Error.new "test_name", Exception.new("message")
7
+ error.make_exception_marshallable
8
+
9
+ assert_kind_of MarshallableExceptionWrapper, error.exception
10
+ end
11
+
12
+ test "calling make_exception_marshallable twice only wraps exception once" do
13
+ error = ::Test::Unit::Error.new "test_name", Exception.new("message")
14
+ error.make_exception_marshallable
15
+ error.make_exception_marshallable
16
+
17
+ assert_kind_of MarshallableExceptionWrapper, error.exception
18
+ end
19
+
20
+ test "error is accessible as normal when it has not been made marshallable" do
21
+ error = ::Test::Unit::Error.new "test_name", e = Exception.new("message")
22
+ assert_equal e, error.exception
23
+ end
24
+
25
+ test "resolve_marshallable_exception restores the original exception" do
26
+ error = ::Test::Unit::Error.new "test_name", Exception.new("message")
27
+ error.make_exception_marshallable
28
+ error.resolve_marshallable_exception
29
+
30
+ assert_kind_of Exception, error.exception
31
+ assert_equal 'message', error.exception.message
32
+ end
33
+
34
+ test "resolve_marshallable_exception does not fail when exception has not been made marshallable" do
35
+ error = ::Test::Unit::Error.new "test_name", Exception.new("message")
36
+ error.resolve_marshallable_exception
37
+
38
+ assert_kind_of Exception, error.exception
39
+ assert_equal 'message', error.exception.message
40
+ end
39
41
  end
40
42
  end
@@ -1,7 +1,11 @@
1
1
  require File.dirname(__FILE__) + "/../../test_helper"
2
2
 
3
- unit_tests do
4
- test "no filters constant has empty filters" do
5
- assert_equal [], DeepTest::Test::Runner::NO_FILTERS.filters
3
+ module DeepTest
4
+ module Test
5
+ unit_tests do
6
+ test "no filters constant has empty filters" do
7
+ assert_equal [], Runner::NO_FILTERS.filters
8
+ end
9
+ end
6
10
  end
7
11
  end
@@ -1,79 +1,107 @@
1
1
  require File.dirname(__FILE__) + "/../../test_helper"
2
2
 
3
- unit_tests do
4
- test "run yields name for start and finished of underlying suite" do
5
- suite = Test::Unit::TestSuite.new("name")
6
- supervised_suite = DeepTest::Test::SupervisedTestSuite.new(suite, DeepTest::SimpleTestBlackboard.new)
7
-
8
- yielded = []
9
- supervised_suite.run(stub_everything) do |channel,name|
10
- yielded << [channel,name]
11
- end
3
+ module DeepTest
4
+ module Test
5
+ unit_tests do
6
+ test "run yields name for start and finished of underlying suite" do
7
+ options = Options.new({})
8
+ suite = ::Test::Unit::TestSuite.new("name")
9
+ supervised_suite = SupervisedTestSuite.new(suite, TestCentralCommand.start(options))
10
+
11
+ yielded = []
12
+ supervised_suite.run(stub_everything) do |channel,name|
13
+ yielded << [channel,name]
14
+ end
15
+
16
+ assert_equal [[::Test::Unit::TestSuite::STARTED, "name"],
17
+ [::Test::Unit::TestSuite::FINISHED, "name"]], yielded
18
+ end
12
19
 
13
- assert_equal [[Test::Unit::TestSuite::STARTED, "name"],
14
- [Test::Unit::TestSuite::FINISHED, "name"]], yielded
15
- end
20
+ test "run adds tests to central_command and reads results" do
21
+ options = Options.new({})
22
+ class AddTestsTestCase < ::Test::Unit::TestCase
23
+ test("1") {}
24
+ test("2") {assert_equal true, false}
25
+ end
26
+ central_command = TestCentralCommand.start options
27
+ supervised_suite = SupervisedTestSuite.new(AddTestsTestCase.suite, central_command)
28
+ result = ::Test::Unit::TestResult.new
29
+
30
+ agent = ThreadAgent.new options
31
+ Timeout.timeout(5) do
32
+ supervised_suite.run(result) {}
33
+ end
34
+ central_command.done_with_work
35
+ agent.wait_until_done
36
+
37
+ assert_equal 2, result.run_count
38
+ assert_equal 1, result.failure_count
39
+ end
16
40
 
17
- test "run adds tests to blackboard and reads results" do
18
- test_case_class = Class.new(Test::Unit::TestCase) do
19
- test("1") {}
20
- test("2") {assert_equal true, false}
21
- end
22
- blackboard = DeepTest::SimpleTestBlackboard.new
23
- supervised_suite = DeepTest::Test::SupervisedTestSuite.new(test_case_class.suite, blackboard)
24
- result = Test::Unit::TestResult.new
41
+ test "agent errors are counted as errors" do
42
+ options = Options.new({})
43
+ class AgentErrorTestCase < ::Test::Unit::TestCase
44
+ test("1") {}
45
+ end
25
46
 
26
- worker = ThreadWorker.new(blackboard, 2)
27
- Timeout.timeout(5) do
28
- supervised_suite.run(result) {}
29
- end
30
- worker.wait_until_done
47
+ central_command = TestCentralCommand.start options
48
+ supervised_suite = SupervisedTestSuite.new(AgentErrorTestCase.suite, central_command)
49
+ result = ::Test::Unit::TestResult.new
31
50
 
32
- assert_equal 2, result.run_count
33
- assert_equal 1, result.failure_count
34
- end
51
+ central_command.write_result Agent::Error.new(AgentErrorTestCase.new("test_1"), RuntimeError.new)
52
+ capture_stdout {supervised_suite.run(result) {}}
53
+
54
+ assert_equal 1, result.error_count
55
+ end
35
56
 
36
- test "worker errors are counted as errors" do
37
- test_case = Class.new(Test::Unit::TestCase) do
38
- test("1") {}
39
- end.new("test_1")
57
+ test "multiple agent errors are consolidated to be one error" do
58
+ options = Options.new({})
59
+ class MultipleAgentErrorTestCase < ::Test::Unit::TestCase
60
+ test("1") {}; test("2") {}
61
+ end
62
+ central_command = TestCentralCommand.start options
63
+ supervised_suite = SupervisedTestSuite.new(MultipleAgentErrorTestCase.suite, central_command)
64
+ result = ::Test::Unit::TestResult.new
40
65
 
41
- blackboard = DeepTest::SimpleTestBlackboard.new
42
- supervised_suite = DeepTest::Test::SupervisedTestSuite.new(test_case, blackboard)
43
- result = Test::Unit::TestResult.new
66
+ central_command.write_result Agent::Error.new(MultipleAgentErrorTestCase.new("test_1"), RuntimeError.new)
67
+ central_command.write_result Agent::Error.new(MultipleAgentErrorTestCase.new("test_2"), RuntimeError.new)
68
+ capture_stdout {supervised_suite.run(result) {}}
44
69
 
45
- blackboard.write_result DeepTest::Worker::Error.new(test_case, RuntimeError.new)
46
- capture_stdout {supervised_suite.run(result) {}}
70
+ assert_equal 1, result.error_count
71
+ end
47
72
 
48
- assert_equal 1, result.error_count
49
- end
73
+ test "run yields test case finished events" do
74
+ options = Options.new({})
75
+ class RunYieldsTestCase < ::Test::Unit::TestCase
76
+ test("1") {}
77
+ end
78
+ test_case = RunYieldsTestCase.new("test_1")
50
79
 
51
- test "run yields test case finished events" do
52
- test_case = Class.new(Test::Unit::TestCase) do
53
- test("1") {}
54
- end.new("test_1")
80
+ central_command = TestCentralCommand.start options
81
+ supervised_suite = SupervisedTestSuite.new(test_case, central_command)
55
82
 
56
- blackboard = DeepTest::SimpleTestBlackboard.new
57
- supervised_suite = DeepTest::Test::SupervisedTestSuite.new(test_case, blackboard)
83
+ yielded = []
58
84
 
59
- yielded = []
85
+ agent = ThreadAgent.new options
86
+ Timeout.timeout(5) do
87
+ supervised_suite.run(stub_everything) do |channel,name|
88
+ yielded << [channel, name]
89
+ end
90
+ end
91
+ central_command.done_with_work
92
+ agent.wait_until_done
60
93
 
61
- worker = ThreadWorker.new(blackboard, 1)
62
- Timeout.timeout(5) do
63
- supervised_suite.run(stub_everything) do |channel,name|
64
- yielded << [channel, name]
94
+ assert_equal true, yielded.include?([::Test::Unit::TestCase::FINISHED, test_case.name])
65
95
  end
66
- end
67
- worker.wait_until_done
68
96
 
69
- assert_equal true, yielded.include?([::Test::Unit::TestCase::FINISHED, test_case.name])
70
- end
71
-
72
- test "has same size as underlying suite" do
73
- suite = Test::Unit::TestSuite.new("name")
74
- suite << "test"
75
- supervised_suite = DeepTest::Test::SupervisedTestSuite.new(suite, DeepTest::SimpleTestBlackboard.new)
76
-
77
- assert_equal suite.size, supervised_suite.size
97
+ test "has same size as underlying suite" do
98
+ options = Options.new({})
99
+ suite = ::Test::Unit::TestSuite.new("name")
100
+ suite << "test"
101
+ supervised_suite = SupervisedTestSuite.new(suite, TestCentralCommand.start(options))
102
+
103
+ assert_equal suite.size, supervised_suite.size
104
+ end
105
+ end
78
106
  end
79
107
  end
@@ -1,81 +1,85 @@
1
1
  require File.dirname(__FILE__) + "/../../test_helper"
2
2
 
3
- unit_tests do
4
- test "add_to adds correct run_count" do
5
- result_1 = DeepTest::Test::WorkResult.new "test_name"
6
- result_1.add_run
7
- result_1.add_run
8
-
9
- result_2 = Test::Unit::TestResult.new
10
- result_1.add_to result_2
11
-
12
- assert_equal 2, result_2.run_count
13
- end
14
-
15
- test "add_to adds correct assertion_count" do
16
- result_1 = DeepTest::Test::WorkResult.new "test_name"
17
- result_1.add_assertion
18
- result_1.add_assertion
19
-
20
- result_2 = Test::Unit::TestResult.new
21
- result_1.add_to result_2
22
-
23
- assert_equal 2, result_2.assertion_count
24
- end
25
-
26
- test "add_to adds correct errors" do
27
- result_1 = DeepTest::Test::WorkResult.new "test_name"
28
- result_1.add_error(e = Test::Unit::Error.new("test_name", Exception.new))
29
-
30
- result_2 = Test::Unit::TestResult.new
31
- result_1.add_to result_2
32
-
33
- assert_equal [e], result_2.instance_variable_get(:@errors)
34
- end
35
-
36
-
37
- test "add_to adds correct failures" do
38
- result_1 = DeepTest::Test::WorkResult.new "test_name"
39
- result_1.add_failure(:failure)
40
-
41
- result_2 = Test::Unit::TestResult.new
42
- result_1.add_to result_2
43
-
44
- assert_equal [:failure], result_2.instance_variable_get(:@failures)
45
- end
46
-
47
- test "add_error wraps exceptions" do
48
- result = DeepTest::Test::WorkResult.new "test_name"
49
- result.add_error Test::Unit::Error.new(
50
- "test_wraps_exceptions",
51
- SomeCustomException.new("the exception message")
52
- )
53
-
54
- error = result.instance_variable_get("@errors").last
55
- assert_kind_of DeepTest::MarshallableExceptionWrapper, error.exception
56
- end
57
-
58
- test "add_to unwraps exception" do
59
- work_result = DeepTest::Test::WorkResult.new "test_name"
60
- work_result.add_error Test::Unit::Error.new(
61
- "test_wraps_exceptions",
62
- SomeCustomException.new("the exception message")
63
- )
64
-
65
- test_result = ::Test::Unit::TestResult.new
66
- work_result.add_to(test_result)
67
-
68
- error = test_result.instance_variable_get("@errors").last
69
- assert_kind_of SomeCustomException, error.exception
70
- end
71
-
72
- test "failed due to deadlock" do
73
- result = DeepTest::Test::WorkResult.new "test_name"
74
- begin
75
- raise FakeDeadlockError.new
76
- rescue => ex
77
- result.add_error Test::Unit::Error.new("test_", ex)
3
+ module DeepTest
4
+ module Test
5
+ unit_tests do
6
+ test "add_to adds correct run_count" do
7
+ result_1 = WorkResult.new "test_name"
8
+ result_1.add_run
9
+ result_1.add_run
10
+
11
+ result_2 = ::Test::Unit::TestResult.new
12
+ result_1.add_to result_2
13
+
14
+ assert_equal 2, result_2.run_count
15
+ end
16
+
17
+ test "add_to adds correct assertion_count" do
18
+ result_1 = WorkResult.new "test_name"
19
+ result_1.add_assertion
20
+ result_1.add_assertion
21
+
22
+ result_2 = ::Test::Unit::TestResult.new
23
+ result_1.add_to result_2
24
+
25
+ assert_equal 2, result_2.assertion_count
26
+ end
27
+
28
+ test "add_to adds correct errors" do
29
+ result_1 = WorkResult.new "test_name"
30
+ result_1.add_error(e = ::Test::Unit::Error.new("test_name", Exception.new))
31
+
32
+ result_2 = ::Test::Unit::TestResult.new
33
+ result_1.add_to result_2
34
+
35
+ assert_equal [e], result_2.instance_variable_get(:@errors)
36
+ end
37
+
38
+
39
+ test "add_to adds correct failures" do
40
+ result_1 = WorkResult.new "test_name"
41
+ result_1.add_failure(:failure)
42
+
43
+ result_2 = ::Test::Unit::TestResult.new
44
+ result_1.add_to result_2
45
+
46
+ assert_equal [:failure], result_2.instance_variable_get(:@failures)
47
+ end
48
+
49
+ test "add_error wraps exceptions" do
50
+ result = WorkResult.new "test_name"
51
+ result.add_error ::Test::Unit::Error.new(
52
+ "test_wraps_exceptions",
53
+ SomeCustomException.new("the exception message")
54
+ )
55
+
56
+ error = result.instance_variable_get("@errors").last
57
+ assert_kind_of MarshallableExceptionWrapper, error.exception
58
+ end
59
+
60
+ test "add_to unwraps exception" do
61
+ work_result = WorkResult.new "test_name"
62
+ work_result.add_error ::Test::Unit::Error.new(
63
+ "test_wraps_exceptions",
64
+ SomeCustomException.new("the exception message")
65
+ )
66
+
67
+ test_result = ::Test::Unit::TestResult.new
68
+ work_result.add_to(test_result)
69
+
70
+ error = test_result.instance_variable_get("@errors").last
71
+ assert_kind_of SomeCustomException, error.exception
72
+ end
73
+
74
+ test "failed due to deadlock" do
75
+ result = WorkResult.new "test_name"
76
+ begin
77
+ raise FakeDeadlockError.new
78
+ rescue => ex
79
+ result.add_error ::Test::Unit::Error.new("test_", ex)
80
+ end
81
+ assert_equal true, result.failed_due_to_deadlock?
82
+ end
78
83
  end
79
- assert_equal true, result.failed_due_to_deadlock?
80
84
  end
81
85
  end
@@ -1,61 +1,63 @@
1
1
  require File.dirname(__FILE__) + "/../../test_helper"
2
2
 
3
- unit_tests do
4
- test "returns passed result for passing test" do
5
- work_unit = DeepTest::Test::WorkUnit.new TestFactory.passing_test
6
- assert_equal true, work_unit.run.passed?
7
- end
3
+ module DeepTest
4
+ module Test
5
+ unit_tests do
6
+ test "returns passed result for passing test" do
7
+ work_unit = WorkUnit.new TestFactory.passing_test
8
+ assert_equal true, work_unit.run.passed?
9
+ end
8
10
 
9
- test "returns failed result for failing test" do
10
- work_unit = DeepTest::Test::WorkUnit.new TestFactory.failing_test
11
- assert_equal false, work_unit.run.passed?
12
- end
11
+ test "returns failed result for failing test" do
12
+ work_unit = WorkUnit.new TestFactory.failing_test
13
+ assert_equal false, work_unit.run.passed?
14
+ end
13
15
 
14
- test "returns result with identifier of test name" do
15
- test = TestFactory.passing_test
16
- work_unit = DeepTest::Test::WorkUnit.new test
17
- assert_equal test.name, work_unit.run.identifier
18
- end
16
+ test "returns result with identifier of test name" do
17
+ test = TestFactory.passing_test
18
+ work_unit = WorkUnit.new test
19
+ assert_equal test.name, work_unit.run.identifier
20
+ end
19
21
 
20
- test "capturing stdout" do
21
- work_unit = DeepTest::Test::WorkUnit.new TestFactory.passing_test_with_stdout
22
- assert_equal "message printed to stdout", work_unit.run.output
23
- end
24
-
25
- test "retry on deadlock" do
26
- work_unit = DeepTest::Test::WorkUnit.new TestFactory.deadlock_once_test
27
- result = work_unit.run
28
- assert_equal 0, result.error_count
29
- assert_equal 0, result.failure_count
30
- assert_equal 1, result.assertion_count
31
- end
32
-
33
- test "skip on deadlock twice" do
34
- work_unit = DeepTest::Test::WorkUnit.new TestFactory.deadlock_always_test
35
- result = work_unit.run
36
- assert_equal 0, result.error_count
37
- assert_equal 0, result.failure_count
38
- assert_equal 0, result.assertion_count
39
- end
40
-
41
- test "set test_name as identifier on deadlock" do
42
- test = TestFactory.deadlock_always_test
43
- work_unit = DeepTest::Test::WorkUnit.new test
44
- assert_equal test.name, work_unit.run.identifier
45
- end
22
+ test "capturing stdout" do
23
+ work_unit = WorkUnit.new TestFactory.passing_test_with_stdout
24
+ assert_equal "message printed to stdout", work_unit.run.output
25
+ end
26
+
27
+ test "retry on deadlock" do
28
+ work_unit = WorkUnit.new TestFactory.deadlock_once_test
29
+ result = work_unit.run
30
+ assert_equal 0, result.error_count
31
+ assert_equal 0, result.failure_count
32
+ assert_equal 1, result.assertion_count
33
+ end
34
+
35
+ test "skip on deadlock twice" do
36
+ work_unit = WorkUnit.new TestFactory.deadlock_always_test
37
+ result = work_unit.run
38
+ assert_equal 0, result.error_count
39
+ assert_equal 0, result.failure_count
40
+ assert_equal 0, result.assertion_count
41
+ end
42
+
43
+ test "set test_name as identifier on deadlock" do
44
+ test = TestFactory.deadlock_always_test
45
+ work_unit = WorkUnit.new test
46
+ assert_equal test.name, work_unit.run.identifier
47
+ end
46
48
 
47
- test "equality is based on test_case" do
48
- test_case_1 = TestFactory.passing_test
49
- test_case_2 = TestFactory.failing_test
50
- assert_equal DeepTest::Test::WorkUnit.new(test_case_1),
51
- DeepTest::Test::WorkUnit.new(test_case_1)
49
+ test "equality is based on test_case" do
50
+ test_case_1 = TestFactory.passing_test
51
+ test_case_2 = TestFactory.failing_test
52
+ assert_equal WorkUnit.new(test_case_1), WorkUnit.new(test_case_1)
52
53
 
53
- assert_not_equal DeepTest::Test::WorkUnit.new(test_case_1),
54
- DeepTest::Test::WorkUnit.new(test_case_2)
55
- end
54
+ assert_not_equal WorkUnit.new(test_case_1), WorkUnit.new(test_case_2)
55
+ end
56
56
 
57
- test "to_s is delegated to test case" do
58
- test_case = TestFactory.passing_test
59
- assert_equal test_case.to_s, DeepTest::Test::WorkUnit.new(test_case).to_s
57
+ test "to_s is delegated to test case" do
58
+ test_case = TestFactory.passing_test
59
+ assert_equal test_case.to_s, WorkUnit.new(test_case).to_s
60
+ end
61
+ end
60
62
  end
61
63
  end