GUnit 0.2.1 → 0.2.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.
- data/VERSION +1 -1
- data/gunit.gemspec +9 -1
- data/lib/gunit/exception_response.rb +1 -0
- data/lib/gunit/fail_response.rb +0 -22
- data/lib/gunit/pass_response.rb +1 -0
- data/lib/gunit/test_response.rb +48 -0
- data/lib/gunit/test_runner.rb +2 -2
- data/lib/gunit/to_do_response.rb +1 -0
- data/lib/gunit/verification.rb +3 -6
- data/test/unit/exception_response_test.rb +19 -0
- data/test/unit/fail_response_test.rb +4 -88
- data/test/unit/pass_response_test.rb +19 -0
- data/test/unit/test_response_test.rb +102 -0
- data/test/unit/test_runner_test.rb +11 -8
- data/test/unit/to_do_response_test.rb +19 -0
- data/test/unit/verification_test.rb +24 -1
- metadata +9 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/gunit.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{GUnit}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Greg Sterndale"]
|
@@ -44,14 +44,18 @@ Gem::Specification.new do |s|
|
|
44
44
|
"test/test_helper.rb",
|
45
45
|
"test/unit/assertions_test.rb",
|
46
46
|
"test/unit/context_test.rb",
|
47
|
+
"test/unit/exception_response_test.rb",
|
47
48
|
"test/unit/exercise_test.rb",
|
48
49
|
"test/unit/fail_response_test.rb",
|
50
|
+
"test/unit/pass_response_test.rb",
|
49
51
|
"test/unit/proc_extensions_test.rb",
|
50
52
|
"test/unit/setup_test.rb",
|
51
53
|
"test/unit/teardown_test.rb",
|
52
54
|
"test/unit/test_case_test.rb",
|
55
|
+
"test/unit/test_response_test.rb",
|
53
56
|
"test/unit/test_runner_test.rb",
|
54
57
|
"test/unit/test_suite_test.rb",
|
58
|
+
"test/unit/to_do_response_test.rb",
|
55
59
|
"test/unit/verification_test.rb"
|
56
60
|
]
|
57
61
|
s.homepage = %q{http://github.com/gsterndale/gunit}
|
@@ -64,14 +68,18 @@ Gem::Specification.new do |s|
|
|
64
68
|
"test/test_helper.rb",
|
65
69
|
"test/unit/assertions_test.rb",
|
66
70
|
"test/unit/context_test.rb",
|
71
|
+
"test/unit/exception_response_test.rb",
|
67
72
|
"test/unit/exercise_test.rb",
|
68
73
|
"test/unit/fail_response_test.rb",
|
74
|
+
"test/unit/pass_response_test.rb",
|
69
75
|
"test/unit/proc_extensions_test.rb",
|
70
76
|
"test/unit/setup_test.rb",
|
71
77
|
"test/unit/teardown_test.rb",
|
72
78
|
"test/unit/test_case_test.rb",
|
79
|
+
"test/unit/test_response_test.rb",
|
73
80
|
"test/unit/test_runner_test.rb",
|
74
81
|
"test/unit/test_suite_test.rb",
|
82
|
+
"test/unit/to_do_response_test.rb",
|
75
83
|
"test/unit/verification_test.rb"
|
76
84
|
]
|
77
85
|
|
data/lib/gunit/fail_response.rb
CHANGED
@@ -1,29 +1,7 @@
|
|
1
1
|
module GUnit
|
2
2
|
|
3
3
|
class FailResponse < TestResponse
|
4
|
-
|
5
4
|
DEFAULT_MESSAGE = 'Fail'
|
6
|
-
|
7
|
-
attr_accessor :message
|
8
|
-
attr_reader :backtrace, :line_number, :file_name
|
9
|
-
|
10
|
-
# FailResponse.new("my message")
|
11
|
-
def initialize(*args)
|
12
|
-
self.message = args.find{|a| a.is_a?(String) } || DEFAULT_MESSAGE
|
13
|
-
self.backtrace = args.find{|a| a.is_a?(Array) } || []
|
14
|
-
end
|
15
|
-
|
16
|
-
def backtrace=(a=[])
|
17
|
-
@backtrace = a
|
18
|
-
@line_number = nil
|
19
|
-
@backtrace.find do |trace|
|
20
|
-
trace =~ /([\w\.]+):(\d+):/
|
21
|
-
$1 != 'assertions.rb' and @file_name = $1 and @line_number = $2 and @file_name = $1
|
22
|
-
end
|
23
|
-
@line_number = @line_number ? @line_number.to_i : nil
|
24
|
-
@backtrace
|
25
|
-
end
|
26
|
-
|
27
5
|
end
|
28
6
|
|
29
7
|
end
|
data/lib/gunit/pass_response.rb
CHANGED
data/lib/gunit/test_response.rb
CHANGED
@@ -1,6 +1,54 @@
|
|
1
1
|
module GUnit
|
2
2
|
|
3
3
|
class TestResponse
|
4
|
+
|
5
|
+
DEFAULT_MESSAGE = ''
|
6
|
+
|
7
|
+
attr_accessor :message
|
8
|
+
attr_reader :backtrace, :line_number, :file_name
|
9
|
+
|
10
|
+
# FailResponse.new("my message")
|
11
|
+
def initialize(*args)
|
12
|
+
self.message = args.find{|a| a.is_a?(String) } || self.class::DEFAULT_MESSAGE
|
13
|
+
self.backtrace = args.find{|a| a.is_a?(Array) } || []
|
14
|
+
end
|
15
|
+
|
16
|
+
def backtrace=(a=[])
|
17
|
+
@backtrace = a
|
18
|
+
discover_file_name
|
19
|
+
discover_line_number
|
20
|
+
@backtrace
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
def discover_line_number
|
26
|
+
return @line_number = nil if self.scrubbed_backtrace.empty?
|
27
|
+
self.scrubbed_backtrace.first =~ /[\/\w\.]+:(\d+)/
|
28
|
+
@line_number = $1
|
29
|
+
@line_number = @line_number ? @line_number.to_i : nil
|
30
|
+
end
|
31
|
+
|
32
|
+
def discover_file_name
|
33
|
+
return @file_name = nil if self.scrubbed_backtrace.empty?
|
34
|
+
self.scrubbed_backtrace.first =~ /([\w\.]+):\d+/
|
35
|
+
@file_name = $1
|
36
|
+
end
|
37
|
+
|
38
|
+
def scrubbed_backtrace
|
39
|
+
@backtrace.select do |trace|
|
40
|
+
!self.class.blacklisted?(trace)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.blacklisted?(trace)
|
45
|
+
trace =~ /\A([\/\w\.]+):\d+.+\z/
|
46
|
+
path = $1
|
47
|
+
return false unless path
|
48
|
+
dir = path.split('/')[-2]
|
49
|
+
dir && dir == 'gunit'
|
50
|
+
end
|
51
|
+
|
4
52
|
end
|
5
53
|
|
6
54
|
end
|
data/lib/gunit/test_runner.rb
CHANGED
@@ -54,8 +54,8 @@ module GUnit
|
|
54
54
|
|
55
55
|
unless self.silent
|
56
56
|
@io.puts ""
|
57
|
-
|
58
|
-
@io.puts "#{
|
57
|
+
@responses.each do |response|
|
58
|
+
@io.puts "#{response.message} (#{response.file_name}:#{response.line_number})" unless response.is_a?(GUnit::PassResponse)
|
59
59
|
end
|
60
60
|
@io.puts "#{@responses.length} verifications: #{passes.length} passed, #{fails.length} failed, #{exceptions.length} exceptions, #{to_dos.length} to-dos"
|
61
61
|
end
|
data/lib/gunit/to_do_response.rb
CHANGED
data/lib/gunit/verification.rb
CHANGED
@@ -19,15 +19,12 @@ module GUnit
|
|
19
19
|
bound_task.call
|
20
20
|
PassResponse.new
|
21
21
|
else
|
22
|
-
ToDoResponse.new
|
22
|
+
ToDoResponse.new(self.message, Kernel.caller)
|
23
23
|
end
|
24
24
|
rescue GUnit::AssertionFailure => e
|
25
|
-
# require 'rubygems'
|
26
|
-
# require 'ruby-debug'
|
27
|
-
# debugger
|
28
25
|
FailResponse.new(e.message, e.backtrace)
|
29
|
-
rescue ::
|
30
|
-
ExceptionResponse.new
|
26
|
+
rescue ::Exception => e
|
27
|
+
ExceptionResponse.new(e.message, e.backtrace)
|
31
28
|
end
|
32
29
|
end
|
33
30
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
2
|
+
|
3
|
+
class GUnit::ExceptionResponseTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@exception_response1 = GUnit::ExceptionResponse.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_it_is_a_test_response
|
10
|
+
assert @exception_response1.is_a?(GUnit::TestResponse)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_has_default_message
|
14
|
+
assert_not_nil @exception_response1.message
|
15
|
+
assert @exception_response1.message != ''
|
16
|
+
assert_equal GUnit::ExceptionResponse::DEFAULT_MESSAGE, @exception_response1.message
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -6,98 +6,14 @@ class GUnit::FailResponseTest < Test::Unit::TestCase
|
|
6
6
|
@fail_response1 = GUnit::FailResponse.new
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
assert @fail_response1.is_a?(GUnit::
|
9
|
+
def test_it_is_a_test_response
|
10
|
+
assert @fail_response1.is_a?(GUnit::TestResponse)
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_has_default_message
|
14
14
|
assert_not_nil @fail_response1.message
|
15
15
|
assert @fail_response1.message != ''
|
16
|
+
assert_equal GUnit::FailResponse::DEFAULT_MESSAGE, @fail_response1.message
|
16
17
|
end
|
17
|
-
|
18
|
-
def test_has_default_backtrace
|
19
|
-
assert_not_nil @fail_response1.backtrace
|
20
|
-
assert_equal [], @fail_response1.backtrace
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_message_setter
|
24
|
-
message = "Whoops."
|
25
|
-
@fail_response1.message = message
|
26
|
-
assert_equal message, @fail_response1.message
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_backtrace_setter
|
30
|
-
backtrace = ['a', 'b', 'c']
|
31
|
-
@fail_response1.backtrace = backtrace
|
32
|
-
assert_equal backtrace, @fail_response1.backtrace
|
33
|
-
end
|
34
|
-
|
35
|
-
# FailResponse.new('my fixtures')
|
36
|
-
def test_initialize_with_string
|
37
|
-
message = 'Uhohs'
|
38
|
-
@fail_response2 = GUnit::FailResponse.new(message)
|
39
|
-
assert @fail_response2.message === message
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_initialize_with_array
|
43
|
-
backtrace = ['a', 'b', 'c']
|
44
|
-
@fail_response2 = GUnit::FailResponse.new(backtrace)
|
45
|
-
assert_equal backtrace, @fail_response2.backtrace
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_initialize_with_string_and_array
|
49
|
-
message = 'Uhohs'
|
50
|
-
backtrace = ['a', 'b', 'c']
|
51
|
-
@fail_response2 = GUnit::FailResponse.new(message, backtrace)
|
52
|
-
assert_equal backtrace, @fail_response2.backtrace
|
53
|
-
assert @fail_response2.message === message
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_line_number
|
57
|
-
assert_nil @fail_response1.line_number
|
58
|
-
|
59
|
-
line_number = 63
|
60
|
-
backtrace = ["./samples/../lib/gunit/assertions.rb:23:in `assert'",
|
61
|
-
"./samples/../lib/gunit/assertions.rb:79:in `assert_raises'",
|
62
|
-
"samples/foo_sample.rb:#{line_number}:in `__bind_1264219445_661068'",
|
63
|
-
"./samples/../lib/gunit/verification.rb:19:in `call'",
|
64
|
-
"./samples/../lib/gunit/verification.rb:19:in `run'",
|
65
|
-
"./samples/../lib/gunit/test_case.rb:108:in `test_not_exceptional'",
|
66
|
-
"./samples/../lib/gunit/test_case.rb:38:in `send'",
|
67
|
-
"./samples/../lib/gunit/test_case.rb:38:in `run'",
|
68
|
-
"./samples/../lib/gunit/test_suite.rb:21:in `run'",
|
69
|
-
"./samples/../lib/gunit/test_suite.rb:16:in `each'",
|
70
|
-
"./samples/../lib/gunit/test_suite.rb:16:in `run'",
|
71
|
-
"./samples/../lib/gunit/test_runner.rb:44:in `run'",
|
72
|
-
"./samples/../lib/gunit/test_runner.rb:41:in `each'",
|
73
|
-
"./samples/../lib/gunit/test_runner.rb:41:in `run'",
|
74
|
-
"samples/foo_sample.rb:177"]
|
75
|
-
@fail_response2 = GUnit::FailResponse.new(backtrace)
|
76
|
-
assert_equal line_number, @fail_response2.line_number
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_file_name
|
80
|
-
assert_nil @fail_response1.file_name
|
81
|
-
|
82
|
-
file_name = 'my_test.rb'
|
83
|
-
backtrace = ["./samples/../lib/gunit/assertions.rb:23:in `assert'",
|
84
|
-
"./samples/../lib/gunit/assertions.rb:79:in `assert_raises'",
|
85
|
-
"samples/#{file_name}:63:in `__bind_1264219445_661068'",
|
86
|
-
"./samples/../lib/gunit/verification.rb:19:in `call'",
|
87
|
-
"./samples/../lib/gunit/verification.rb:19:in `run'",
|
88
|
-
"./samples/../lib/gunit/test_case.rb:108:in `test_not_exceptional'",
|
89
|
-
"./samples/../lib/gunit/test_case.rb:38:in `send'",
|
90
|
-
"./samples/../lib/gunit/test_case.rb:38:in `run'",
|
91
|
-
"./samples/../lib/gunit/test_suite.rb:21:in `run'",
|
92
|
-
"./samples/../lib/gunit/test_suite.rb:16:in `each'",
|
93
|
-
"./samples/../lib/gunit/test_suite.rb:16:in `run'",
|
94
|
-
"./samples/../lib/gunit/test_runner.rb:44:in `run'",
|
95
|
-
"./samples/../lib/gunit/test_runner.rb:41:in `each'",
|
96
|
-
"./samples/../lib/gunit/test_runner.rb:41:in `run'",
|
97
|
-
"samples/foo_sample.rb:177"]
|
98
|
-
@fail_response2 = GUnit::FailResponse.new(backtrace)
|
99
|
-
assert_equal file_name, @fail_response2.file_name
|
100
|
-
end
|
101
|
-
|
102
|
-
|
18
|
+
|
103
19
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
2
|
+
|
3
|
+
class GUnit::PassResponseTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@pass_response1 = GUnit::PassResponse.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_it_is_a_test_response
|
10
|
+
assert @pass_response1.is_a?(GUnit::TestResponse)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_has_default_message
|
14
|
+
assert_not_nil @pass_response1.message
|
15
|
+
assert @pass_response1.message != ''
|
16
|
+
assert_equal GUnit::PassResponse::DEFAULT_MESSAGE, @pass_response1.message
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
2
|
+
|
3
|
+
class GUnit::TestResponseTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@test_response1 = GUnit::TestResponse.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_it_is_a_test_response
|
10
|
+
assert @test_response1.is_a?(GUnit::TestResponse)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_has_default_message
|
14
|
+
assert_not_nil @test_response1.message
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_has_default_backtrace
|
18
|
+
assert_not_nil @test_response1.backtrace
|
19
|
+
assert_equal [], @test_response1.backtrace
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_message_setter
|
23
|
+
message = "Whoops."
|
24
|
+
@test_response1.message = message
|
25
|
+
assert_equal message, @test_response1.message
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_backtrace_setter
|
29
|
+
backtrace = ['a', 'b', 'c']
|
30
|
+
@test_response1.backtrace = backtrace
|
31
|
+
assert_equal backtrace, @test_response1.backtrace
|
32
|
+
end
|
33
|
+
|
34
|
+
# TestResponse.new('my fixtures')
|
35
|
+
def test_initialize_with_string
|
36
|
+
message = 'Uhohs'
|
37
|
+
@test_response2 = GUnit::TestResponse.new(message)
|
38
|
+
assert @test_response2.message === message
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_initialize_with_array
|
42
|
+
backtrace = ['a', 'b', 'c']
|
43
|
+
@test_response2 = GUnit::TestResponse.new(backtrace)
|
44
|
+
assert_equal backtrace, @test_response2.backtrace
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_initialize_with_string_and_array
|
48
|
+
message = 'Uhohs'
|
49
|
+
backtrace = ['a', 'b', 'c']
|
50
|
+
@test_response2 = GUnit::TestResponse.new(message, backtrace)
|
51
|
+
assert_equal backtrace, @test_response2.backtrace
|
52
|
+
assert @test_response2.message === message
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_line_number
|
56
|
+
assert_nil @test_response1.line_number
|
57
|
+
|
58
|
+
line_number = 63
|
59
|
+
backtrace = ["./samples/../lib/gunit/assertions.rb:23:in `assert'",
|
60
|
+
"./samples/../lib/gunit/assertions.rb:79:in `assert_raises'",
|
61
|
+
"samples/foo_sample.rb:#{line_number}:in `__bind_1264219445_661068'",
|
62
|
+
"./samples/../lib/gunit/verification.rb:19:in `call'",
|
63
|
+
"./samples/../lib/gunit/verification.rb:19:in `run'",
|
64
|
+
"./samples/../lib/gunit/test_case.rb:108:in `test_not_exceptional'",
|
65
|
+
"./samples/../lib/gunit/test_case.rb:38:in `send'",
|
66
|
+
"./samples/../lib/gunit/test_case.rb:38:in `run'",
|
67
|
+
"./samples/../lib/gunit/test_suite.rb:21:in `run'",
|
68
|
+
"./samples/../lib/gunit/test_suite.rb:16:in `each'",
|
69
|
+
"./samples/../lib/gunit/test_suite.rb:16:in `run'",
|
70
|
+
"./samples/../lib/gunit/test_runner.rb:44:in `run'",
|
71
|
+
"./samples/../lib/gunit/test_runner.rb:41:in `each'",
|
72
|
+
"./samples/../lib/gunit/test_runner.rb:41:in `run'",
|
73
|
+
"samples/foo_sample.rb:177"]
|
74
|
+
@test_response2 = GUnit::TestResponse.new(backtrace)
|
75
|
+
assert_equal line_number, @test_response2.line_number
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_file_name
|
79
|
+
assert_nil @test_response1.file_name
|
80
|
+
|
81
|
+
file_name = 'my_test.rb'
|
82
|
+
backtrace = ["./samples/../lib/gunit/assertions.rb:23:in `assert'",
|
83
|
+
"./samples/../lib/gunit/assertions.rb:79:in `assert_raises'",
|
84
|
+
"samples/#{file_name}:63:in `__bind_1264219445_661068'",
|
85
|
+
"./samples/../lib/gunit/verification.rb:19:in `call'",
|
86
|
+
"./samples/../lib/gunit/verification.rb:19:in `run'",
|
87
|
+
"./samples/../lib/gunit/test_case.rb:108:in `test_not_exceptional'",
|
88
|
+
"./samples/../lib/gunit/test_case.rb:38:in `send'",
|
89
|
+
"./samples/../lib/gunit/test_case.rb:38:in `run'",
|
90
|
+
"./samples/../lib/gunit/test_suite.rb:21:in `run'",
|
91
|
+
"./samples/../lib/gunit/test_suite.rb:16:in `each'",
|
92
|
+
"./samples/../lib/gunit/test_suite.rb:16:in `run'",
|
93
|
+
"./samples/../lib/gunit/test_runner.rb:44:in `run'",
|
94
|
+
"./samples/../lib/gunit/test_runner.rb:41:in `each'",
|
95
|
+
"./samples/../lib/gunit/test_runner.rb:41:in `run'",
|
96
|
+
"samples/foo_sample.rb:177"]
|
97
|
+
@test_response2 = GUnit::TestResponse.new(backtrace)
|
98
|
+
assert_equal file_name, @test_response2.file_name
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
end
|
@@ -65,15 +65,17 @@ class GUnit::TestRunnerTest < Test::Unit::TestCase
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def test_run_not_silent
|
68
|
-
fail_response_message = "Whoops. Failed."
|
69
|
-
line_number = 63
|
70
|
-
file_name = 'my_test.rb'
|
71
|
-
backtrace = ["samples/#{file_name}:#{line_number}:in `my_method'"]
|
72
68
|
test_response1 = GUnit::PassResponse.new
|
73
|
-
|
74
|
-
|
69
|
+
fail_response_message = "Whoops. Failed."
|
70
|
+
fail_line_number = 63
|
71
|
+
fail_file_name = 'my_test.rb'
|
72
|
+
backtrace =
|
73
|
+
test_response2 = GUnit::FailResponse.new(fail_response_message, ["samples/#{fail_file_name}:#{fail_line_number}:in `my_method'"])
|
74
|
+
exception_response_message = "Exceptional"
|
75
|
+
exception_line_number = 72
|
76
|
+
exception_file_name = 'my_other_test.rb'
|
77
|
+
test_response3 = GUnit::ExceptionResponse.new(exception_response_message, ["samples/#{exception_file_name}:#{exception_line_number}:in `my_method'"])
|
75
78
|
test_response4 = GUnit::ToDoResponse.new
|
76
|
-
|
77
79
|
@test_runner.silent = false
|
78
80
|
io = mock
|
79
81
|
io.expects(:print).with(GUnit::TestRunner::PASS_CHAR).at_least(1)
|
@@ -81,7 +83,8 @@ class GUnit::TestRunnerTest < Test::Unit::TestCase
|
|
81
83
|
io.expects(:print).with(GUnit::TestRunner::EXCEPTION_CHAR).at_least(1)
|
82
84
|
io.expects(:print).with(GUnit::TestRunner::TODO_CHAR).at_least(1)
|
83
85
|
io.stubs(:puts)
|
84
|
-
io.expects(:puts).with() { |value| value =~ /#{fail_response_message}/ && value =~ /#{
|
86
|
+
io.expects(:puts).with() { |value| value =~ /#{fail_response_message}/ && value =~ /#{fail_file_name}/ && value =~ /#{fail_line_number}/ }.at_least(1)
|
87
|
+
io.expects(:puts).with() { |value| value =~ /#{exception_response_message}/ && value =~ /#{exception_file_name}/ && value =~ /#{exception_line_number}/ }.at_least(1)
|
85
88
|
@test_runner.io = io
|
86
89
|
|
87
90
|
test_suite = GUnit::TestSuite.new
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
2
|
+
|
3
|
+
class GUnit::ToDoResponseTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@to_do_response1 = GUnit::ToDoResponse.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_it_is_a_test_response
|
10
|
+
assert @to_do_response1.is_a?(GUnit::TestResponse)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_has_default_message
|
14
|
+
assert_not_nil @to_do_response1.message
|
15
|
+
assert @to_do_response1.message != ''
|
16
|
+
assert_equal GUnit::ToDoResponse::DEFAULT_MESSAGE, @to_do_response1.message
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -71,10 +71,27 @@ class GUnit::VerificationTest < Test::Unit::TestCase
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_run_with_task_is_nil
|
74
|
+
message = 'Not dun yet'
|
75
|
+
stack = ["./samples/../lib/gunit/verification.rb:25:in `test_not_dun_yet'",
|
76
|
+
"./samples/../lib/gunit/verification.rb:25:in `test_not_dun_yet'",
|
77
|
+
"./samples/../lib/gunit/test_case.rb:38:in `send'",
|
78
|
+
"./samples/../lib/gunit/test_case.rb:38:in `run'",
|
79
|
+
"./samples/../lib/gunit/test_suite.rb:21:in `run'",
|
80
|
+
"./samples/../lib/gunit/test_suite.rb:16:in `each'",
|
81
|
+
"./samples/../lib/gunit/test_suite.rb:16:in `run'",
|
82
|
+
"./samples/../lib/gunit/test_runner.rb:44:in `run'",
|
83
|
+
"./samples/../lib/gunit/test_runner.rb:41:in `each'",
|
84
|
+
"./samples/../lib/gunit/test_runner.rb:41:in `run'",
|
85
|
+
"samples/foo_sample.rb:177"]
|
86
|
+
to_do_response = GUnit::ToDoResponse.new(message, stack)
|
87
|
+
@verification1.message = message
|
74
88
|
@verification1.task = nil
|
89
|
+
GUnit::ToDoResponse.expects(:new).with{|m,b| m == message && b.is_a?(Array) }.once.returns(to_do_response)
|
75
90
|
response = @verification1.run
|
76
91
|
assert response.is_a?(GUnit::TestResponse)
|
77
92
|
assert response.is_a?(GUnit::ToDoResponse)
|
93
|
+
assert_equal message, response.message
|
94
|
+
assert_equal stack, response.backtrace
|
78
95
|
end
|
79
96
|
|
80
97
|
def test_run_with_binding
|
@@ -101,10 +118,16 @@ class GUnit::VerificationTest < Test::Unit::TestCase
|
|
101
118
|
end
|
102
119
|
|
103
120
|
def test_run_with_random_exception
|
104
|
-
|
121
|
+
message = "boooooooom"
|
122
|
+
backtrace = ['ohnoes']
|
123
|
+
exception = Exception.new(message)
|
124
|
+
exception.set_backtrace(backtrace)
|
125
|
+
@verification1.task = lambda { raise exception }
|
105
126
|
response = @verification1.run
|
106
127
|
assert response.is_a?(GUnit::TestResponse)
|
107
128
|
assert response.is_a?(GUnit::ExceptionResponse)
|
129
|
+
assert_equal message, response.message
|
130
|
+
assert_equal backtrace, response.backtrace
|
108
131
|
end
|
109
132
|
|
110
133
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: GUnit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Sterndale
|
@@ -50,14 +50,18 @@ files:
|
|
50
50
|
- test/test_helper.rb
|
51
51
|
- test/unit/assertions_test.rb
|
52
52
|
- test/unit/context_test.rb
|
53
|
+
- test/unit/exception_response_test.rb
|
53
54
|
- test/unit/exercise_test.rb
|
54
55
|
- test/unit/fail_response_test.rb
|
56
|
+
- test/unit/pass_response_test.rb
|
55
57
|
- test/unit/proc_extensions_test.rb
|
56
58
|
- test/unit/setup_test.rb
|
57
59
|
- test/unit/teardown_test.rb
|
58
60
|
- test/unit/test_case_test.rb
|
61
|
+
- test/unit/test_response_test.rb
|
59
62
|
- test/unit/test_runner_test.rb
|
60
63
|
- test/unit/test_suite_test.rb
|
64
|
+
- test/unit/to_do_response_test.rb
|
61
65
|
- test/unit/verification_test.rb
|
62
66
|
has_rdoc: true
|
63
67
|
homepage: http://github.com/gsterndale/gunit
|
@@ -92,12 +96,16 @@ test_files:
|
|
92
96
|
- test/test_helper.rb
|
93
97
|
- test/unit/assertions_test.rb
|
94
98
|
- test/unit/context_test.rb
|
99
|
+
- test/unit/exception_response_test.rb
|
95
100
|
- test/unit/exercise_test.rb
|
96
101
|
- test/unit/fail_response_test.rb
|
102
|
+
- test/unit/pass_response_test.rb
|
97
103
|
- test/unit/proc_extensions_test.rb
|
98
104
|
- test/unit/setup_test.rb
|
99
105
|
- test/unit/teardown_test.rb
|
100
106
|
- test/unit/test_case_test.rb
|
107
|
+
- test/unit/test_response_test.rb
|
101
108
|
- test/unit/test_runner_test.rb
|
102
109
|
- test/unit/test_suite_test.rb
|
110
|
+
- test/unit/to_do_response_test.rb
|
103
111
|
- test/unit/verification_test.rb
|