GUnit 0.1.2

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.
@@ -0,0 +1,129 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'test_helper')
2
+
3
+ # class MyClassTest < GUnit::TestCase
4
+ # setup "Some fixtures should be created here"
5
+ #
6
+ # context "An instance of MyClass"
7
+ # setup "my fixture with attributes" do
8
+ # ...
9
+ # end
10
+ # end
11
+ # end
12
+
13
+ class GUnit::ContextTest < Test::Unit::TestCase
14
+
15
+ def setup
16
+ @context1 = GUnit::Context.new
17
+ end
18
+
19
+ def test_it_is_a_setup
20
+ assert @context1.is_a?(GUnit::Context)
21
+ end
22
+
23
+ def test_has_default_message
24
+ assert_not_nil @context1.message
25
+ assert @context1.message.is_a?(String)
26
+ end
27
+
28
+ def test_message_setter
29
+ message = "Set something up"
30
+ @context1.message = message
31
+ assert_equal message, @context1.message
32
+ end
33
+
34
+ def test_setups_setter
35
+ setups = [GUnit::Setup.new, GUnit::Setup.new]
36
+ @context1.setups = setups
37
+ assert_equal setups, @context1.setups
38
+ end
39
+
40
+ def test_teardowns_setter
41
+ teardowns = [GUnit::Teardown.new, GUnit::Teardown.new]
42
+ @context1.teardowns = teardowns
43
+ assert_equal teardowns, @context1.teardowns
44
+ end
45
+
46
+ def test_parent_setter
47
+ parent = GUnit::Context.new
48
+ @context1.parent = parent
49
+ assert_equal parent, @context1.parent
50
+ end
51
+
52
+ def test_message_with_parent
53
+ parent = GUnit::Context.new
54
+ parent.message = "Mom"
55
+ message = "Kid"
56
+ @context1.parent = parent
57
+ @context1.message = message
58
+ assert_equal parent.message + ' ' + message, @context1.all_message
59
+ end
60
+
61
+ def test_setups_with_parent
62
+ parent = GUnit::Context.new
63
+ parent.setups = [GUnit::Setup.new, GUnit::Setup.new]
64
+ setups = [GUnit::Setup.new, GUnit::Setup.new]
65
+ @context1.parent = parent
66
+ @context1.setups = setups
67
+ assert_equal parent.setups + setups, @context1.all_setups
68
+ end
69
+
70
+ def test_teardowns_with_parent
71
+ parent = GUnit::Context.new
72
+ parent.teardowns = [GUnit::Teardown.new, GUnit::Teardown.new]
73
+ teardowns = [GUnit::Teardown.new, GUnit::Teardown.new]
74
+ @context1.parent = parent
75
+ @context1.teardowns = teardowns
76
+ assert_equal parent.teardowns + teardowns, @context1.all_teardowns
77
+ end
78
+
79
+ # Context.new('my fixtures')
80
+ def test_initialize_with_one_arg
81
+ message = 'my fixtures'
82
+ @setup2 = GUnit::Context.new(message)
83
+ assert @setup2.message === message
84
+ end
85
+
86
+ # Context.new('my fixtures'){ @foo = "bar" }
87
+ def test_initialize_with_one_arg_and_block
88
+ message = 'my fixtures'
89
+ task = (@foo = "bar")
90
+ @setup2 = GUnit::Context.new(message) { (@foo = "bar") }
91
+ assert message === @setup2.message
92
+ assert task === @setup2.task.call
93
+ end
94
+
95
+ def test_run_with_task_called_returns_true
96
+ @context1.task = Proc.new { true }
97
+ response = @context1.run
98
+ assert response === true
99
+ end
100
+
101
+ def test_run_with_task_called_returns_false
102
+ @context1.task = Proc.new { false }
103
+ response = @context1.run
104
+ assert response === true
105
+ end
106
+
107
+ def test_run_with_task_is_false
108
+ @context1.task = false
109
+ response = @context1.run
110
+ assert response === true
111
+ end
112
+
113
+ def test_run_with_task_is_nil
114
+ @context1.task = nil
115
+ response = @context1.run
116
+ assert response === true
117
+ end
118
+
119
+ def test_run_with_binding
120
+ obj = Object.new
121
+ obj.instance_variable_set("@foo", "bar")
122
+ @context1.task = Proc.new { instance_variable_set("@foo", "zip") }
123
+ @context1.run
124
+ assert_equal "bar", obj.instance_variable_get("@foo")
125
+ @context1.run(obj)
126
+ assert_equal "zip", obj.instance_variable_get("@foo")
127
+ end
128
+
129
+ end
@@ -0,0 +1,31 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'test_helper')
2
+
3
+ class GUnit::FailResponseTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @fail_response1 = GUnit::FailResponse.new
7
+ end
8
+
9
+ def test_it_is_a_fail_response
10
+ assert @fail_response1.is_a?(GUnit::FailResponse)
11
+ end
12
+
13
+ def test_has_default_message
14
+ assert_not_nil @fail_response1.message
15
+ assert @fail_response1.message != ''
16
+ end
17
+
18
+ def test_message_setter
19
+ message = "Whoops."
20
+ @fail_response1.message = message
21
+ assert_equal message, @fail_response1.message
22
+ end
23
+
24
+ # FailResponse.new('my fixtures')
25
+ def test_initialize_with_one_arg
26
+ message = 'Uhohs'
27
+ @fail_response2 = GUnit::FailResponse.new(message)
28
+ assert @fail_response2.message === message
29
+ end
30
+
31
+ end
@@ -0,0 +1,24 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'test_helper')
2
+
3
+ class GUnit::ProcExtensionsTest < Test::Unit::TestCase
4
+
5
+ @@proc = Proc.new { bound_to }
6
+
7
+ def self.bound_to
8
+ :class
9
+ end
10
+
11
+ def bound_to
12
+ :instance
13
+ end
14
+
15
+ def test_bind
16
+ p = @@proc
17
+ assert self.class.bound_to == :class
18
+ assert p.call == :class
19
+ p = p.bind(self)
20
+ assert self.bound_to == :instance
21
+ assert p.call == :instance
22
+ end
23
+
24
+ end
@@ -0,0 +1,97 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'test_helper')
2
+
3
+ # class MyClassTest < GUnit::TestCase
4
+ # setup "Some fixtures should be created here"
5
+ #
6
+ # context "An instance of MyClass"
7
+ # setup "my fixture with attributes" do
8
+ # ...
9
+ # end
10
+ # end
11
+ # end
12
+
13
+ class GUnit::SetupTest < Test::Unit::TestCase
14
+
15
+ def setup
16
+ @setup1 = GUnit::Setup.new
17
+ end
18
+
19
+ def test_it_is_a_setup
20
+ assert @setup1.is_a?(GUnit::Setup)
21
+ end
22
+
23
+ def test_has_default_message
24
+ assert_not_nil @setup1.message
25
+ end
26
+
27
+ def test_message_setter
28
+ message = "Set something up"
29
+ @setup1.message = message
30
+ assert_equal message, @setup1.message
31
+ end
32
+
33
+ # Setup.new('my fixtures')
34
+ def test_initialize_with_one_arg
35
+ message = 'my fixtures'
36
+ @setup2 = GUnit::Setup.new(message)
37
+ assert @setup2.message === message
38
+ end
39
+
40
+ # Setup.new('my fixtures'){ @foo = "bar" }
41
+ def test_initialize_with_one_arg_and_block
42
+ message = 'my fixtures'
43
+ task = (@foo = "bar")
44
+ @setup2 = GUnit::Setup.new(message) { (@foo = "bar") }
45
+ assert message === @setup2.message
46
+ assert task === @setup2.task.call
47
+ end
48
+
49
+ def test_run_with_task_called_returns_true
50
+ @setup1.task = Proc.new { true }
51
+ response = @setup1.run
52
+ assert response === true
53
+ end
54
+
55
+ def test_run_with_task_called_returns_false
56
+ @setup1.task = Proc.new { false }
57
+ response = @setup1.run
58
+ assert response === true
59
+ end
60
+
61
+ def test_run_with_task_is_false
62
+ @setup1.task = false
63
+ response = @setup1.run
64
+ assert response === true
65
+ end
66
+
67
+ def test_run_with_task_is_nil
68
+ @setup1.task = nil
69
+ response = @setup1.run
70
+ assert response === true
71
+ end
72
+
73
+ def test_run_with_assertion_failure_exception
74
+ @setup1.task = lambda { raise GUnit::AssertionFailure }
75
+ response = @setup1.run
76
+ assert response.is_a?(GUnit::TestResponse)
77
+ assert response.is_a?(GUnit::FailResponse)
78
+ end
79
+
80
+ def test_run_with_random_exception
81
+ @setup1.task = lambda { raise 'Boom' }
82
+ response = @setup1.run
83
+ assert response.is_a?(GUnit::TestResponse)
84
+ assert response.is_a?(GUnit::ExceptionResponse)
85
+ end
86
+
87
+ def test_run_with_binding
88
+ obj = Object.new
89
+ obj.instance_variable_set("@foo", "bar")
90
+ @setup1.task = Proc.new { instance_variable_set("@foo", "zip") }
91
+ @setup1.run
92
+ assert_equal "bar", obj.instance_variable_get("@foo")
93
+ @setup1.run(obj)
94
+ assert_equal "zip", obj.instance_variable_get("@foo")
95
+ end
96
+
97
+ end
@@ -0,0 +1,97 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'test_helper')
2
+
3
+ # class MyClassTest < GUnit::TestCase
4
+ # teardown "Delete some fixtures here"
5
+ #
6
+ # context "An instance of MyClass"
7
+ # teardown "delete my fixture" do
8
+ # ...
9
+ # end
10
+ # end
11
+ # end
12
+
13
+ class GUnit::TeardownTest < Test::Unit::TestCase
14
+
15
+ def setup
16
+ @teardown1 = GUnit::Teardown.new
17
+ end
18
+
19
+ def test_it_is_a_teardown
20
+ assert @teardown1.is_a?(GUnit::Teardown)
21
+ end
22
+
23
+ def test_has_default_message
24
+ assert_not_nil @teardown1.message
25
+ end
26
+
27
+ def test_message_setter
28
+ message = "Set something up"
29
+ @teardown1.message = message
30
+ assert_equal message, @teardown1.message
31
+ end
32
+
33
+ # Teardown.new('my fixtures')
34
+ def test_initialize_with_one_arg
35
+ message = 'my fixtures'
36
+ @teardown2 = GUnit::Teardown.new(message)
37
+ assert @teardown2.message === message
38
+ end
39
+
40
+ # Teardown.new('my fixtures'){ @foo = "bar" }
41
+ def test_initialize_with_one_arg_and_block
42
+ message = 'my fixtures'
43
+ task = (@foo = "bar")
44
+ @teardown2 = GUnit::Teardown.new(message) { (@foo = "bar") }
45
+ assert message === @teardown2.message
46
+ assert task === @teardown2.task.call
47
+ end
48
+
49
+ def test_run_with_task_called_returns_true
50
+ @teardown1.task = Proc.new { true }
51
+ response = @teardown1.run
52
+ assert response === true
53
+ end
54
+
55
+ def test_run_with_task_called_returns_false
56
+ @teardown1.task = Proc.new { false }
57
+ response = @teardown1.run
58
+ assert response === true
59
+ end
60
+
61
+ def test_run_with_task_is_false
62
+ @teardown1.task = false
63
+ response = @teardown1.run
64
+ assert response === true
65
+ end
66
+
67
+ def test_run_with_task_is_nil
68
+ @teardown1.task = nil
69
+ response = @teardown1.run
70
+ assert response === true
71
+ end
72
+
73
+ def test_run_with_assertion_failure_exception
74
+ @teardown1.task = lambda { raise GUnit::AssertionFailure }
75
+ response = @teardown1.run
76
+ assert response.is_a?(GUnit::TestResponse)
77
+ assert response.is_a?(GUnit::FailResponse)
78
+ end
79
+
80
+ def test_run_with_random_exception
81
+ @teardown1.task = lambda { raise 'Boom' }
82
+ response = @teardown1.run
83
+ assert response.is_a?(GUnit::TestResponse)
84
+ assert response.is_a?(GUnit::ExceptionResponse)
85
+ end
86
+
87
+ def test_run_with_binding
88
+ obj = Object.new
89
+ obj.instance_variable_set("@foo", "bar")
90
+ @teardown1.task = Proc.new { instance_variable_set("@foo", "zip") }
91
+ @teardown1.run
92
+ assert_equal "bar", obj.instance_variable_get("@foo")
93
+ @teardown1.run(obj)
94
+ assert_equal "zip", obj.instance_variable_get("@foo")
95
+ end
96
+
97
+ end
@@ -0,0 +1,201 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'test_helper')
2
+
3
+ class MyClass
4
+ end
5
+
6
+ class MyClassTest < GUnit::TestCase
7
+ def test_one
8
+ end
9
+ def test_two
10
+ end
11
+ def not_a_test_method
12
+ end
13
+ end
14
+
15
+ class GUnit::TestCaseTest < Test::Unit::TestCase
16
+
17
+ def setup
18
+ @my_test_case = MyClassTest.new
19
+ end
20
+
21
+ def test_it_is_a_test_case
22
+ assert @my_test_case.is_a?(GUnit::TestCase)
23
+ end
24
+
25
+ def test_method_name_setter_getter
26
+ method_name = "my_method"
27
+ assert_not_equal method_name, @my_test_case.method_name
28
+ @my_test_case.method_name = method_name
29
+ assert_equal method_name, @my_test_case.method_name
30
+ end
31
+
32
+ def test_constructor
33
+ method_name = "my_method"
34
+ @my_test_case1 = MyClassTest.new()
35
+ assert_not_equal method_name, @my_test_case1.method_name
36
+ @my_test_case1 = MyClassTest.new(method_name)
37
+ assert_equal method_name, @my_test_case1.method_name
38
+ end
39
+
40
+ def test_run_calls_method_name
41
+ method_name = "my_method"
42
+ @my_test_case1 = MyClassTest.new(method_name)
43
+ @my_test_case1.expects(method_name.to_sym)
44
+ @my_test_case1.run
45
+ end
46
+
47
+ def test_run_returns_method_result
48
+ method_name = "my_method"
49
+ result = "my result"
50
+ @my_test_case1 = MyClassTest.new(method_name)
51
+ @my_test_case1.expects(method_name.to_sym).returns(result)
52
+ assert_equal result, @my_test_case1.run
53
+ end
54
+
55
+ def test_message_to_test_method_name
56
+ msg = "Check for expected outcome"
57
+ method_name = MyClassTest.message_to_test_method_name(msg)
58
+ assert method_name.is_a?(Symbol)
59
+ assert method_name.to_s =~ /#{MyClassTest::TEST_METHOD_PREFIX}_check_for_expected_outcome/
60
+ end
61
+
62
+ def test_verify_creates_instance_method
63
+ method_count = MyClassTest.instance_methods.length
64
+ args = "TODO add some feature"
65
+ dynamic_method_name = MyClassTest.verify(args)
66
+ assert_equal method_count + 1, MyClassTest.instance_methods.length
67
+ assert dynamic_method_name.to_s =~ /#{MyClassTest::TEST_METHOD_PREFIX}/
68
+ assert MyClassTest.instance_methods.include?(dynamic_method_name.to_s)
69
+ verification = GUnit::Verification.new
70
+ todo = GUnit::ToDoResponse.new
71
+ verification.expects(:run).returns(todo)
72
+ GUnit::Verification.expects(:new).with(args).returns(verification)
73
+ assert_equal todo, MyClassTest.new.send(dynamic_method_name)
74
+ end
75
+
76
+ def test_verify_with_block_creates_instance_method
77
+ method_count = MyClassTest.instance_methods.length
78
+ args = "The truth"
79
+ blk = Proc.new{ true }
80
+ dynamic_method_name = MyClassTest.verify(args)
81
+ assert_equal method_count + 1, MyClassTest.instance_methods.length
82
+ assert dynamic_method_name.to_s =~ /#{MyClassTest::TEST_METHOD_PREFIX}/
83
+ assert MyClassTest.new.respond_to?(dynamic_method_name)
84
+ verification = GUnit::Verification.new
85
+ pass = GUnit::PassResponse.new
86
+ verification.expects(:run).returns(pass)
87
+ # TODO how to set expectation that blk is passed to new() ???
88
+ GUnit::Verification.expects(:new).with(args).returns(verification)
89
+ assert_equal pass, MyClassTest.new.send(dynamic_method_name)
90
+ end
91
+
92
+ def test_run_runs_setups
93
+ MyClassTest.setup { @foo = "bar" }
94
+ method_name = "test_one"
95
+ @my_test_case1 = MyClassTest.new(method_name)
96
+ @my_test_case1.run
97
+ assert_equal "bar", @my_test_case1.instance_variable_get("@foo")
98
+ end
99
+
100
+ def test_run_runs_teardowns
101
+ @my_test_case2 = MyClassTest.new
102
+ MyClassTest.setup { @foo = "bar" }
103
+ MyClassTest.teardown { @foo = "zip" }
104
+ method_name = "test_one"
105
+ @my_test_case2 = MyClassTest.new(method_name)
106
+ @my_test_case2.run
107
+ assert_equal "zip", @my_test_case2.instance_variable_get("@foo")
108
+ end
109
+
110
+ def test_run_runs_teardowns_in_reverse_order
111
+ @my_test_case3 = MyClassTest.new
112
+ MyClassTest.setup { @foo = "bar" }
113
+ MyClassTest.teardown { @foo = "zip" }
114
+ MyClassTest.teardown { @foo = "zap" }
115
+ method_name = "test_one"
116
+ @my_test_case3 = MyClassTest.new(method_name)
117
+ @my_test_case3.run
118
+ assert_equal "zip", @my_test_case3.instance_variable_get("@foo")
119
+ end
120
+
121
+ def test_test_methods
122
+ assert MyClassTest.test_methods.include?(:test_one)
123
+ assert MyClassTest.test_methods.include?(:test_two)
124
+ assert ! MyClassTest.test_methods.include?(:not_a_test_method)
125
+ end
126
+
127
+ def test_suite_returns_test_suite_with_test_cases
128
+ test_suite = MyClassTest.suite
129
+ assert test_suite.is_a?(GUnit::TestSuite)
130
+ assert test_suite.tests.find{|t| t.method_name == :test_one }
131
+ assert test_suite.tests.find{|t| t.method_name == :test_two }
132
+ assert_nil test_suite.tests.find{|t| t.method_name == :not_a_test_method}
133
+ end
134
+
135
+ def test_assert_true
136
+ response = @my_test_case.assert(1==1)
137
+ assert response === true
138
+ end
139
+
140
+ def test_assert_false
141
+ assert_raise GUnit::AssertionFailure do
142
+ @my_test_case.assert(1==0)
143
+ end
144
+ end
145
+
146
+ def test_assert_with_exception_raised
147
+ boom = lambda{ raise RuntimeError }
148
+ assert_raise RuntimeError do
149
+ @my_test_case.assert( boom )
150
+ end
151
+ end
152
+
153
+ def test_verify_inside_context_defines_test_method_with_context
154
+ context_msg = "In some context"
155
+ verify_msg = "This should be the case A"
156
+ MyClassTest.context(context_msg) do
157
+ verify(verify_msg) { true }
158
+ end
159
+ method_name = MyClassTest.message_to_test_method_name(verify_msg)
160
+ assert MyClassTest.method_defined?(method_name)
161
+ context = MyClassTest.context_for_method(method_name)
162
+ assert_not_nil context
163
+ assert_equal context_msg, context.message
164
+ end
165
+
166
+ def test_setup_and_teardown_inside_context_creates_context_with_setup_and_teardown
167
+ context_msg = "In some context"
168
+ setup_msg = "Given this"
169
+ teardown_msg = "Housekeeping"
170
+ verify_msg = "This should be the case B"
171
+ MyClassTest.context(context_msg) do
172
+ setup(setup_msg) { @foo = "abc" }
173
+ teardown(teardown_msg) { @foo = "def" }
174
+ verify(verify_msg) { true }
175
+ end
176
+ method_name = MyClassTest.message_to_test_method_name(verify_msg)
177
+ context = MyClassTest.context_for_method(method_name)
178
+ assert_equal setup_msg, context.setups.last.message
179
+ assert_equal teardown_msg, context.teardowns.last.message
180
+ end
181
+
182
+ def test_context_creates_context_with_parent
183
+ context_msg = "In some context"
184
+ verify_msg = "This should be the case C"
185
+ MyClassTest.context(context_msg) do
186
+ verify(verify_msg) { true }
187
+ end
188
+ method_name = MyClassTest.message_to_test_method_name(verify_msg)
189
+ context = MyClassTest.context_for_method(method_name)
190
+ assert_not_nil context.parent
191
+ assert context.parent.is_a?(GUnit::Context)
192
+ end
193
+
194
+ def test_test_method_outside_context_block_has_context
195
+ method_name = 'test_one'
196
+ context = MyClassTest.context_for_method(method_name)
197
+ assert_not_nil context
198
+ assert context.is_a?(GUnit::Context)
199
+ end
200
+
201
+ end
@@ -0,0 +1,118 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'test_helper')
2
+
3
+ class GUnit::TestRunnerTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @test_runner = GUnit::TestRunner.new
7
+ io = Object.new
8
+ @test_runner.io = io
9
+ @test_runner.io.stubs(:print)
10
+ @test_runner.io.stubs(:puts)
11
+ end
12
+
13
+ def test_it_is_a_test_runner
14
+ assert @test_runner.is_a?(GUnit::TestRunner)
15
+ end
16
+
17
+ def test_tests_getter_setter
18
+ tests = [GUnit::TestSuite.new, GUnit::TestCase.new]
19
+ assert @test_runner.tests != tests
20
+ @test_runner.tests = tests
21
+ assert @test_runner.tests == tests
22
+ end
23
+
24
+ def test_tests_set_nil_has_empty_tests
25
+ @test_runner.tests = nil
26
+ assert @test_runner.tests.empty?
27
+ assert @test_runner.tests.is_a?(Enumerable)
28
+ end
29
+
30
+ def test_has_empty_responses
31
+ assert @test_runner.responses.empty?
32
+ assert @test_runner.responses.is_a?(Enumerable)
33
+ end
34
+
35
+ def test_silent_default
36
+ assert ! @test_runner.silent
37
+ end
38
+
39
+ def test_silent_getter_setter
40
+ silent = true
41
+ assert @test_runner.silent != silent
42
+ @test_runner.silent = silent
43
+ assert @test_runner.silent === silent
44
+ end
45
+
46
+ def test_io_default
47
+ assert GUnit::TestRunner.new.io == STDOUT
48
+ end
49
+
50
+ def test_silent_getter_setter
51
+ io = mock
52
+ assert @test_runner.io != io
53
+ @test_runner.io = io
54
+ assert @test_runner.io === io
55
+ end
56
+
57
+ def test_run_silent
58
+ @test_runner.io = mock() # fails if any methods on io are called
59
+ @test_runner.silent = true
60
+ test_response1 = GUnit::PassResponse.new
61
+ test_suite = GUnit::TestSuite.new
62
+ test_suite.expects(:run).yields(test_response1)
63
+ @test_runner.tests = [test_suite]
64
+ @test_runner.run
65
+ end
66
+
67
+ def test_run_not_silent
68
+ fail_response_message = "Whoops. Failed."
69
+
70
+ test_response1 = GUnit::PassResponse.new
71
+ test_response2 = GUnit::FailResponse.new(fail_response_message)
72
+ test_response3 = GUnit::ExceptionResponse.new
73
+ test_response4 = GUnit::ToDoResponse.new
74
+
75
+ @test_runner.silent = false
76
+ io = mock
77
+ io.expects(:print).with(GUnit::TestRunner::PASS_CHAR).at_least(1)
78
+ io.expects(:print).with(GUnit::TestRunner::FAIL_CHAR).at_least(1)
79
+ io.expects(:print).with(GUnit::TestRunner::EXCEPTION_CHAR).at_least(1)
80
+ io.expects(:print).with(GUnit::TestRunner::TODO_CHAR).at_least(1)
81
+ io.stubs(:puts)
82
+ io.expects(:puts).with(fail_response_message).at_least(1)
83
+ @test_runner.io = io
84
+
85
+ test_suite = GUnit::TestSuite.new
86
+ test_suite.expects(:run).multiple_yields(test_response1, test_response2, test_response4)
87
+ test_case = GUnit::TestCase.new
88
+ test_case.expects(:run).returns(test_response3)
89
+ @test_runner.tests = [test_suite, test_case]
90
+
91
+ @test_runner.run
92
+ end
93
+
94
+ def test_run_runs_all_tests_saves_responses
95
+ test_response1 = GUnit::PassResponse.new
96
+ test_response2 = GUnit::FailResponse.new
97
+ test_response3 = GUnit::ExceptionResponse.new
98
+ test_response4 = GUnit::ToDoResponse.new
99
+ test_suite = GUnit::TestSuite.new
100
+ test_suite.expects(:run).multiple_yields(test_response1, test_response2, test_response4)
101
+ test_case = GUnit::TestCase.new
102
+ test_case.expects(:run).returns(test_response3)
103
+ @test_runner.tests = [test_suite, test_case]
104
+
105
+ @test_runner.run
106
+
107
+ assert @test_runner.responses.include?(test_response1)
108
+ assert @test_runner.passes.include?(test_response1)
109
+ assert @test_runner.responses.include?(test_response2)
110
+ assert @test_runner.fails.include?(test_response2)
111
+ assert @test_runner.responses.include?(test_response3)
112
+ assert @test_runner.exceptions.include?(test_response3)
113
+ assert @test_runner.responses.include?(test_response4)
114
+ assert @test_runner.to_dos.include?(test_response4)
115
+ assert @test_runner.responses.length == 4
116
+ end
117
+
118
+ end