GUnit 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/gunit.gemspec +2 -2
- data/lib/gunit/fail_response.rb +15 -3
- data/lib/gunit/test_runner.rb +1 -2
- data/lib/gunit/verification.rb +4 -1
- data/test/unit/fail_response_test.rb +73 -1
- data/test/unit/test_runner_test.rb +5 -3
- data/test/unit/verification_test.rb +3 -0
- metadata +2 -2
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/gunit.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
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.1"
|
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"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-23}
|
13
13
|
s.description = %q{GUnit is a fresh new XUnit Test implementation, poppin' a cap in the ass of TestUnit. Just playin'. TestUnit is our boy.}
|
14
14
|
s.email = %q{gsterndale@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/gunit/fail_response.rb
CHANGED
@@ -5,11 +5,23 @@ module GUnit
|
|
5
5
|
DEFAULT_MESSAGE = 'Fail'
|
6
6
|
|
7
7
|
attr_accessor :message
|
8
|
+
attr_reader :backtrace, :line_number, :file_name
|
8
9
|
|
9
10
|
# FailResponse.new("my message")
|
10
|
-
|
11
|
-
|
12
|
-
self.
|
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
|
13
25
|
end
|
14
26
|
|
15
27
|
end
|
data/lib/gunit/test_runner.rb
CHANGED
@@ -55,8 +55,7 @@ module GUnit
|
|
55
55
|
unless self.silent
|
56
56
|
@io.puts ""
|
57
57
|
fails.each do |fail|
|
58
|
-
@io.puts ""
|
59
|
-
@io.puts fail.message
|
58
|
+
@io.puts "#{fail.message} (#{fail.file_name}:#{fail.line_number})"
|
60
59
|
end
|
61
60
|
@io.puts "#{@responses.length} verifications: #{passes.length} passed, #{fails.length} failed, #{exceptions.length} exceptions, #{to_dos.length} to-dos"
|
62
61
|
end
|
data/lib/gunit/verification.rb
CHANGED
@@ -22,7 +22,10 @@ module GUnit
|
|
22
22
|
ToDoResponse.new
|
23
23
|
end
|
24
24
|
rescue GUnit::AssertionFailure => e
|
25
|
-
|
25
|
+
# require 'rubygems'
|
26
|
+
# require 'ruby-debug'
|
27
|
+
# debugger
|
28
|
+
FailResponse.new(e.message, e.backtrace)
|
26
29
|
rescue ::StandardError => e
|
27
30
|
ExceptionResponse.new
|
28
31
|
end
|
@@ -15,17 +15,89 @@ class GUnit::FailResponseTest < Test::Unit::TestCase
|
|
15
15
|
assert @fail_response1.message != ''
|
16
16
|
end
|
17
17
|
|
18
|
+
def test_has_default_backtrace
|
19
|
+
assert_not_nil @fail_response1.backtrace
|
20
|
+
assert_equal [], @fail_response1.backtrace
|
21
|
+
end
|
22
|
+
|
18
23
|
def test_message_setter
|
19
24
|
message = "Whoops."
|
20
25
|
@fail_response1.message = message
|
21
26
|
assert_equal message, @fail_response1.message
|
22
27
|
end
|
23
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
|
+
|
24
35
|
# FailResponse.new('my fixtures')
|
25
|
-
def
|
36
|
+
def test_initialize_with_string
|
26
37
|
message = 'Uhohs'
|
27
38
|
@fail_response2 = GUnit::FailResponse.new(message)
|
28
39
|
assert @fail_response2.message === message
|
29
40
|
end
|
30
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
|
+
|
31
103
|
end
|
@@ -66,9 +66,11 @@ class GUnit::TestRunnerTest < Test::Unit::TestCase
|
|
66
66
|
|
67
67
|
def test_run_not_silent
|
68
68
|
fail_response_message = "Whoops. Failed."
|
69
|
-
|
69
|
+
line_number = 63
|
70
|
+
file_name = 'my_test.rb'
|
71
|
+
backtrace = ["samples/#{file_name}:#{line_number}:in `my_method'"]
|
70
72
|
test_response1 = GUnit::PassResponse.new
|
71
|
-
test_response2 = GUnit::FailResponse.new(fail_response_message)
|
73
|
+
test_response2 = GUnit::FailResponse.new(fail_response_message, backtrace)
|
72
74
|
test_response3 = GUnit::ExceptionResponse.new
|
73
75
|
test_response4 = GUnit::ToDoResponse.new
|
74
76
|
|
@@ -79,7 +81,7 @@ class GUnit::TestRunnerTest < Test::Unit::TestCase
|
|
79
81
|
io.expects(:print).with(GUnit::TestRunner::EXCEPTION_CHAR).at_least(1)
|
80
82
|
io.expects(:print).with(GUnit::TestRunner::TODO_CHAR).at_least(1)
|
81
83
|
io.stubs(:puts)
|
82
|
-
io.expects(:puts).with(fail_response_message
|
84
|
+
io.expects(:puts).with() { |value| value =~ /#{fail_response_message}/ && value =~ /#{file_name}/ && value =~ /#{line_number}/ }.at_least(1)
|
83
85
|
@test_runner.io = io
|
84
86
|
|
85
87
|
test_suite = GUnit::TestSuite.new
|
@@ -89,12 +89,15 @@ class GUnit::VerificationTest < Test::Unit::TestCase
|
|
89
89
|
|
90
90
|
def test_run_with_assertion_failure_exception
|
91
91
|
message = "boooooooom"
|
92
|
+
backtrace = ['ohnoes']
|
92
93
|
assertion_failure = GUnit::AssertionFailure.new(message)
|
94
|
+
assertion_failure.expects(:backtrace).at_least_once.returns(backtrace)
|
93
95
|
@verification1.task = lambda { raise assertion_failure }
|
94
96
|
response = @verification1.run
|
95
97
|
assert response.is_a?(GUnit::TestResponse)
|
96
98
|
assert response.is_a?(GUnit::FailResponse)
|
97
99
|
assert_equal message, response.message
|
100
|
+
assert_equal backtrace, response.backtrace
|
98
101
|
end
|
99
102
|
|
100
103
|
def test_run_with_random_exception
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Sterndale
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-23 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|