test-unit 3.2.1 → 3.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/doc/text/news.md +39 -0
- data/lib/test/unit/assertions.rb +32 -6
- data/lib/test/unit/fixture.rb +3 -0
- data/lib/test/unit/testcase.rb +34 -32
- data/lib/test/unit/version.rb +1 -1
- data/test/test-assertions.rb +20 -3
- data/test/test-test-case.rb +15 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5ef9797f0e6bb2164df6210b3fc09ea7be531c7
|
4
|
+
data.tar.gz: 97e0722669d6218da248bbc5ce936ed729a27b51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 030a52bcad8c962ee1779c32218ac206e4f788245b18588e596d59df860b63268e1fff0435ae8ff7d5f59481ed417a3a0162057dacb024b36df99d11aa689731
|
7
|
+
data.tar.gz: b8bd4af19c8b334a46926871918531472dab173ddb69f5e631f602e27c600d23d2639d1f7a3b36a87fc5b705627e73d0dfe8874c3369122aab986eeebde79921
|
data/README.md
CHANGED
@@ -10,26 +10,26 @@
|
|
10
10
|
|
11
11
|
An xUnit family unit testing framework for Ruby.
|
12
12
|
|
13
|
-
Test::Unit
|
13
|
+
test-unit (Test::Unit) is unit testing framework for Ruby, based on xUnit
|
14
14
|
principles. These were originally designed by Kent Beck, creator of extreme
|
15
15
|
programming software development methodology, for Smalltalk's SUnit. It allows
|
16
16
|
writing tests, checking results and automated testing in Ruby.
|
17
17
|
|
18
18
|
## Features
|
19
19
|
|
20
|
-
*
|
20
|
+
* test-unit 1.2.3 is the original test-unit, taken
|
21
21
|
straight from the ruby distribution. It is being
|
22
22
|
distributed as a gem to allow tool builders to use it as a
|
23
23
|
stand-alone package. (The test framework in ruby is going
|
24
24
|
to radically change very soon).
|
25
25
|
|
26
26
|
* test-unit will be improved actively and may break
|
27
|
-
compatiblity with
|
27
|
+
compatiblity with test-unit 1.2.3. (We will not hope it
|
28
28
|
if it isn't needed.)
|
29
29
|
|
30
30
|
* Some features exist as separated gems like GUI test
|
31
31
|
runner. (Tk, GTK+ and Fox) test-unit-full gem package
|
32
|
-
provides for installing all
|
32
|
+
provides for installing all test-unit related gems
|
33
33
|
easily.
|
34
34
|
|
35
35
|
## How To
|
@@ -43,7 +43,7 @@ writing tests, checking results and automated testing in Ruby.
|
|
43
43
|
% sudo gem install test-unit
|
44
44
|
</pre>
|
45
45
|
|
46
|
-
If you want to use full
|
46
|
+
If you want to use full test-unit features:
|
47
47
|
|
48
48
|
<pre>
|
49
49
|
% sudo gem install test-unit-full
|
data/doc/text/news.md
CHANGED
@@ -1,5 +1,44 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 3.2.3 - 2016-11-02 {#version-3-2-2}
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* Improved Travis CI configuration.
|
8
|
+
[GitHub#123][Patch by Ryunosuke SEATO]
|
9
|
+
|
10
|
+
* Supported Java native exception.
|
11
|
+
[GitHub#126][Reported by Bob Saveland]
|
12
|
+
|
13
|
+
### Fixes
|
14
|
+
|
15
|
+
* doc: Fixed markup. [GitHub#127][Patch by Tomohiro Hashidate]
|
16
|
+
|
17
|
+
* Fixed a bug that `--location=LINE` may not detect a test when
|
18
|
+
fixtures are defined before any tests:
|
19
|
+
|
20
|
+
1 class MyTestCase < Test::Unit::TestCase
|
21
|
+
2 setup do
|
22
|
+
3 end
|
23
|
+
4
|
24
|
+
5 test "xxx" do
|
25
|
+
6 end
|
26
|
+
7 end
|
27
|
+
|
28
|
+
`--location=5` couldn't find the `xxx` test.
|
29
|
+
|
30
|
+
[Reported by Ryota Sasabe]
|
31
|
+
|
32
|
+
### Thanks
|
33
|
+
|
34
|
+
* Ryunosuke Sato
|
35
|
+
|
36
|
+
* Tomohiro Hashidate
|
37
|
+
|
38
|
+
* Bob Saveland
|
39
|
+
|
40
|
+
* Ryota Sasabe
|
41
|
+
|
3
42
|
## 3.2.1 - 2016-07-19 {#version-3-2-1}
|
4
43
|
|
5
44
|
### Improvements
|
data/lib/test/unit/assertions.rb
CHANGED
@@ -2169,19 +2169,45 @@ EOT
|
|
2169
2169
|
expected_exceptions.each do |exception_type|
|
2170
2170
|
if exception_type.instance_of?(Module)
|
2171
2171
|
exception_modules << exception_type
|
2172
|
-
elsif
|
2172
|
+
elsif exception_object?(exception_type)
|
2173
2173
|
exception_objects << exception_type
|
2174
|
-
|
2175
|
-
@test_case.__send__(:assert,
|
2176
|
-
Exception >= exception_type,
|
2177
|
-
"Should expect a class of exception, " +
|
2178
|
-
"#{exception_type}")
|
2174
|
+
elsif exception_class?(exception_type)
|
2179
2175
|
exception_classes << exception_type
|
2176
|
+
else
|
2177
|
+
full_message =
|
2178
|
+
@test_case.__send__(:build_message,
|
2179
|
+
nil,
|
2180
|
+
"<?> must be " +
|
2181
|
+
"a subclass of Exception, " +
|
2182
|
+
"an object of Exception subclasses " +
|
2183
|
+
"or a Module",
|
2184
|
+
exception_type)
|
2185
|
+
@test_case.flunk(full_message)
|
2180
2186
|
end
|
2181
2187
|
end
|
2182
2188
|
[exception_classes, exception_modules, exception_objects]
|
2183
2189
|
end
|
2184
2190
|
|
2191
|
+
def exception_object?(exception_type)
|
2192
|
+
return true if exception_type.is_a?(Exception)
|
2193
|
+
|
2194
|
+
if Object.const_defined?(:Java)
|
2195
|
+
return true if exception_type.is_a?(Java::JavaLang::Throwable)
|
2196
|
+
end
|
2197
|
+
|
2198
|
+
false
|
2199
|
+
end
|
2200
|
+
|
2201
|
+
def exception_class?(exception_type)
|
2202
|
+
return true if exception_type <= Exception
|
2203
|
+
|
2204
|
+
if Object.const_defined?(:Java)
|
2205
|
+
return true if exception_type <= Java::JavaLang::Throwable
|
2206
|
+
end
|
2207
|
+
|
2208
|
+
false
|
2209
|
+
end
|
2210
|
+
|
2185
2211
|
def expected_class?(actual_exception, equality)
|
2186
2212
|
@expected_classes.any? do |expected_class|
|
2187
2213
|
actual_exception.__send__(equality, expected_class)
|
data/lib/test/unit/fixture.rb
CHANGED
@@ -127,6 +127,9 @@ module Test
|
|
127
127
|
if method_name_or_callback.respond_to?(:call)
|
128
128
|
callback = method_name_or_callback
|
129
129
|
method_name = callback_method_name(callback)
|
130
|
+
@test_case.attribute(:source_location,
|
131
|
+
callback.source_location,
|
132
|
+
method_name)
|
130
133
|
@test_case.__send__(:define_method, method_name, &callback)
|
131
134
|
else
|
132
135
|
method_name = method_name_or_callback
|
data/lib/test/unit/testcase.rb
CHANGED
@@ -37,49 +37,51 @@ module Test
|
|
37
37
|
# You can run two hooks before/after a TestCase run.
|
38
38
|
#
|
39
39
|
# Example:
|
40
|
-
#
|
41
|
-
# class
|
42
|
-
#
|
43
|
-
#
|
40
|
+
#
|
41
|
+
# class TestMyClass < Test::Unit::TestCase
|
42
|
+
# class << self
|
43
|
+
# def startup
|
44
|
+
# ...
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# def shutdown
|
48
|
+
# ...
|
49
|
+
# end
|
44
50
|
# end
|
45
51
|
#
|
46
|
-
# def
|
52
|
+
# def setup
|
47
53
|
# ...
|
48
54
|
# end
|
49
|
-
# end
|
50
55
|
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
# def cleanup
|
56
|
-
# ...
|
57
|
-
# end
|
56
|
+
# def cleanup
|
57
|
+
# ...
|
58
|
+
# end
|
58
59
|
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
60
|
+
# def teardown
|
61
|
+
# ...
|
62
|
+
# end
|
62
63
|
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
64
|
+
# def test_my_method1
|
65
|
+
# ...
|
66
|
+
# end
|
66
67
|
#
|
67
|
-
#
|
68
|
-
#
|
68
|
+
# def test_my_method2
|
69
|
+
# ...
|
70
|
+
# end
|
69
71
|
# end
|
70
|
-
# end
|
71
72
|
#
|
72
73
|
# Here is a call order:
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
74
|
+
#
|
75
|
+
# 1. startup
|
76
|
+
# 1. setup
|
77
|
+
# 1. test_my_method1
|
78
|
+
# 1. cleanup
|
79
|
+
# 1. teardown
|
80
|
+
# 1. setup
|
81
|
+
# 1. test_my_method2
|
82
|
+
# 1. cleanup
|
83
|
+
# 1. teardown
|
84
|
+
# 1. shutdown
|
83
85
|
class TestCase
|
84
86
|
include Attribute
|
85
87
|
include Fixture
|
data/lib/test/unit/version.rb
CHANGED
data/test/test-assertions.rb
CHANGED
@@ -513,8 +513,7 @@ EOM
|
|
513
513
|
end
|
514
514
|
|
515
515
|
message = <<-EOM
|
516
|
-
|
517
|
-
<false> is not true.
|
516
|
+
<Object> must be a subclass of Exception, an object of Exception subclasses or a Module.
|
518
517
|
EOM
|
519
518
|
check_fail(message.chomp) do
|
520
519
|
assert_nothing_raised(Object) do
|
@@ -639,6 +638,21 @@ EOM
|
|
639
638
|
end
|
640
639
|
end
|
641
640
|
|
641
|
+
def test_assert_raise_jruby
|
642
|
+
omit("For JRuby") unless Object.const_defined?(:Java)
|
643
|
+
|
644
|
+
exception = Java::JavaLang::StringIndexOutOfBoundsException
|
645
|
+
|
646
|
+
return_value = nil
|
647
|
+
check_nothing_fails(true) do
|
648
|
+
return_value = assert_raise(exception) do
|
649
|
+
Java::JavaLang::String.new("abc").char_at(4)
|
650
|
+
end
|
651
|
+
end
|
652
|
+
check(return_value.instance_of?(exception),
|
653
|
+
"Should have returned #{exception} but was #{return_value.class}")
|
654
|
+
end
|
655
|
+
|
642
656
|
def test_assert_instance_of
|
643
657
|
check_nothing_fails {
|
644
658
|
assert_instance_of(String, "string")
|
@@ -838,7 +852,10 @@ EOM
|
|
838
852
|
rescue ZeroDivisionError
|
839
853
|
end
|
840
854
|
}
|
841
|
-
|
855
|
+
expected_message =
|
856
|
+
"<Object> must be a subclass of Exception, " +
|
857
|
+
"an object of Exception subclasses or a Module."
|
858
|
+
check_fail(expected_message) {
|
842
859
|
assert_nothing_raised(Object) {
|
843
860
|
1 + 1
|
844
861
|
}
|
data/test/test-test-case.rb
CHANGED
@@ -752,6 +752,21 @@ module Test
|
|
752
752
|
child_test_case.test_defined?(:line => line_child),
|
753
753
|
])
|
754
754
|
end
|
755
|
+
|
756
|
+
def test_with_setup
|
757
|
+
line = nil
|
758
|
+
test_case = Class.new(TestCase) do
|
759
|
+
setup do
|
760
|
+
end
|
761
|
+
|
762
|
+
line = __LINE__; test "with setup" do
|
763
|
+
end
|
764
|
+
end
|
765
|
+
assert do
|
766
|
+
test_case.test_defined?(:line => line,
|
767
|
+
:method_name => "test: with setup")
|
768
|
+
end
|
769
|
+
end
|
755
770
|
end
|
756
771
|
end
|
757
772
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-unit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-11-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: power_assert
|
@@ -96,7 +96,7 @@ dependencies:
|
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
description: |
|
99
|
-
Test::Unit
|
99
|
+
test-unit (Test::Unit) is unit testing framework for Ruby, based on xUnit
|
100
100
|
principles. These were originally designed by Kent Beck, creator of extreme
|
101
101
|
programming software development methodology, for Smalltalk's SUnit. It allows
|
102
102
|
writing tests, checking results and automated testing in Ruby.
|
@@ -274,4 +274,3 @@ test_files:
|
|
274
274
|
- test/test-notification.rb
|
275
275
|
- test/test-omission.rb
|
276
276
|
- test/test-test-case.rb
|
277
|
-
has_rdoc:
|