test-unit-ext 0.2.0 → 0.3.0
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/NEWS.en +5 -0
- data/NEWS.ja +5 -0
- data/README.en +1 -1
- data/README.ja +1 -1
- data/Rakefile +7 -2
- data/html/news.html +7 -2
- data/html/news.html.en +7 -2
- data/html/news.html.ja +7 -2
- data/html/readme.html +1 -1
- data/html/readme.html.en +1 -1
- data/html/readme.html.ja +1 -1
- data/lib/test-unit-ext.rb +1 -1
- data/lib/test-unit-ext/attributes.rb +114 -0
- data/lib/test-unit-ext/priority.rb +15 -12
- data/lib/test-unit-ext/version.rb +1 -1
- data/lib/test-unit-ext/xml-report.rb +21 -21
- data/test/{test_metadata.rb → test_attributes.rb} +17 -17
- data/test/test_xml_report.rb +40 -40
- metadata +11 -8
- data/lib/test-unit-ext/metadata.rb +0 -111
data/NEWS.en
CHANGED
data/NEWS.ja
CHANGED
data/README.en
CHANGED
data/README.ja
CHANGED
data/Rakefile
CHANGED
@@ -22,7 +22,7 @@ Test::Unit.run = true
|
|
22
22
|
manifest = File.join(base_dir, "Manifest.txt")
|
23
23
|
manifest_contents = []
|
24
24
|
base_dir_included_components = %w(NEWS.en NEWS.ja README.en README.ja Rakefile)
|
25
|
-
excluded_components = %w(.svn .test-result)
|
25
|
+
excluded_components = %w(.svn .test-result pkg)
|
26
26
|
excluded_suffixes = %w(.png .ps .pdf .o .so .txt)
|
27
27
|
Find.find(base_dir) do |target|
|
28
28
|
target = truncate_base_dir[target]
|
@@ -69,7 +69,12 @@ project = Hoe.new('test-unit-ext', version) do |project|
|
|
69
69
|
project.summary, project.description, = whats_this.split(/\n\n+/, 3)
|
70
70
|
end
|
71
71
|
|
72
|
-
|
72
|
+
spec = project.spec
|
73
|
+
spec.rdoc_options = spec.rdoc_options.collect do |option|
|
74
|
+
option == "README.txt" ? "README.en" : option
|
75
|
+
end
|
76
|
+
spec.extra_rdoc_files += spec.files.grep(/(:?README|NEWS)\.(:?ja|en)\z/)
|
77
|
+
spec.dependencies.delete_if {|dependency| dependency.name == "hoe"}
|
73
78
|
|
74
79
|
rdoc_task = nil
|
75
80
|
if ObjectSpace.each_object(Rake::RDocTask) {|rdoc_task|} != 1
|
data/html/news.html
CHANGED
@@ -9,7 +9,12 @@
|
|
9
9
|
</head>
|
10
10
|
<body>
|
11
11
|
<h1><a name="label-0" id="label-0">NEWS</a></h1><!-- RDLabel: "NEWS" -->
|
12
|
-
<h2><a name="label-1" id="label-1">0.
|
12
|
+
<h2><a name="label-1" id="label-1">0.3.0: 2008-03-10</a></h2><!-- RDLabel: "0.3.0: 2008-03-10" -->
|
13
|
+
<ul>
|
14
|
+
<li>Changed XML report format.</li>
|
15
|
+
<li>Improved search method to find test result directory.</li>
|
16
|
+
</ul>
|
17
|
+
<h2><a name="label-2" id="label-2">0.2.0: 2008-03-03</a></h2><!-- RDLabel: "0.2.0: 2008-03-03" -->
|
13
18
|
<ul>
|
14
19
|
<li>Supported XML report.
|
15
20
|
<ul>
|
@@ -17,7 +22,7 @@
|
|
17
22
|
</ul></li>
|
18
23
|
<li>Supported diff output for assert_equal.</li>
|
19
24
|
</ul>
|
20
|
-
<h2><a name="label-
|
25
|
+
<h2><a name="label-3" id="label-3">0.1.0: 2008-02-21</a></h2><!-- RDLabel: "0.1.0: 2008-02-21" -->
|
21
26
|
<ul>
|
22
27
|
<li>Initial release.</li>
|
23
28
|
</ul>
|
data/html/news.html.en
CHANGED
@@ -9,7 +9,12 @@
|
|
9
9
|
</head>
|
10
10
|
<body>
|
11
11
|
<h1><a name="label-0" id="label-0">NEWS</a></h1><!-- RDLabel: "NEWS" -->
|
12
|
-
<h2><a name="label-1" id="label-1">0.
|
12
|
+
<h2><a name="label-1" id="label-1">0.3.0: 2008-03-10</a></h2><!-- RDLabel: "0.3.0: 2008-03-10" -->
|
13
|
+
<ul>
|
14
|
+
<li>Changed XML report format.</li>
|
15
|
+
<li>Improved search method to find test result directory.</li>
|
16
|
+
</ul>
|
17
|
+
<h2><a name="label-2" id="label-2">0.2.0: 2008-03-03</a></h2><!-- RDLabel: "0.2.0: 2008-03-03" -->
|
13
18
|
<ul>
|
14
19
|
<li>Supported XML report.
|
15
20
|
<ul>
|
@@ -17,7 +22,7 @@
|
|
17
22
|
</ul></li>
|
18
23
|
<li>Supported diff output for assert_equal.</li>
|
19
24
|
</ul>
|
20
|
-
<h2><a name="label-
|
25
|
+
<h2><a name="label-3" id="label-3">0.1.0: 2008-02-21</a></h2><!-- RDLabel: "0.1.0: 2008-02-21" -->
|
21
26
|
<ul>
|
22
27
|
<li>Initial release.</li>
|
23
28
|
</ul>
|
data/html/news.html.ja
CHANGED
@@ -9,7 +9,12 @@
|
|
9
9
|
</head>
|
10
10
|
<body>
|
11
11
|
<h1><a name="label-0" id="label-0">NEWS.ja</a></h1><!-- RDLabel: "NEWS.ja" -->
|
12
|
-
<h2><a name="label-1" id="label-1">0.
|
12
|
+
<h2><a name="label-1" id="label-1">0.3.0: 2008-03-10</a></h2><!-- RDLabel: "0.3.0: 2008-03-10" -->
|
13
|
+
<ul>
|
14
|
+
<li>XML出力形式の変更</li>
|
15
|
+
<li>テスト結果を保存するディレクトリの検索処理を改良</li>
|
16
|
+
</ul>
|
17
|
+
<h2><a name="label-2" id="label-2">0.2.0: 2008-03-03</a></h2><!-- RDLabel: "0.2.0: 2008-03-03" -->
|
13
18
|
<ul>
|
14
19
|
<li>XML出力のサポート。
|
15
20
|
<ul>
|
@@ -17,7 +22,7 @@
|
|
17
22
|
</ul></li>
|
18
23
|
<li>assert_equal時のdiff出力のサポート。</li>
|
19
24
|
</ul>
|
20
|
-
<h2><a name="label-
|
25
|
+
<h2><a name="label-3" id="label-3">0.1.0: 2008-02-21</a></h2><!-- RDLabel: "0.1.0: 2008-02-21" -->
|
21
26
|
<ul>
|
22
27
|
<li>最初のリリース。</li>
|
23
28
|
</ul>
|
data/html/readme.html
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
<h2><a name="label-7" id="label-7">Usage</a></h2><!-- RDLabel: "Usage" -->
|
33
33
|
<pre>require 'test-unit-ext'</pre>
|
34
34
|
<h3><a name="label-8" id="label-8">Priority</a></h3><!-- RDLabel: "Priority" -->
|
35
|
-
<h3><a name="label-9" id="label-9">
|
35
|
+
<h3><a name="label-9" id="label-9">Attributes</a></h3><!-- RDLabel: "Attributes" -->
|
36
36
|
<h2><a name="label-10" id="label-10">Thanks</a></h2><!-- RDLabel: "Thanks" -->
|
37
37
|
<ul>
|
38
38
|
<li>...</li>
|
data/html/readme.html.en
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
<h2><a name="label-7" id="label-7">Usage</a></h2><!-- RDLabel: "Usage" -->
|
33
33
|
<pre>require 'test-unit-ext'</pre>
|
34
34
|
<h3><a name="label-8" id="label-8">Priority</a></h3><!-- RDLabel: "Priority" -->
|
35
|
-
<h3><a name="label-9" id="label-9">
|
35
|
+
<h3><a name="label-9" id="label-9">Attributes</a></h3><!-- RDLabel: "Attributes" -->
|
36
36
|
<h2><a name="label-10" id="label-10">Thanks</a></h2><!-- RDLabel: "Thanks" -->
|
37
37
|
<ul>
|
38
38
|
<li>...</li>
|
data/html/readme.html.ja
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
<h2><a name="label-7" id="label-7">使用法</a></h2><!-- RDLabel: "使用法" -->
|
33
33
|
<pre>require 'test-unit-ext'</pre>
|
34
34
|
<h3><a name="label-8" id="label-8">優先度</a></h3><!-- RDLabel: "優先度" -->
|
35
|
-
<h3><a name="label-9" id="label-9"
|
35
|
+
<h3><a name="label-9" id="label-9">属性</a></h3><!-- RDLabel: "属性" -->
|
36
36
|
<h2><a name="label-10" id="label-10">感謝</a></h2><!-- RDLabel: "感謝" -->
|
37
37
|
<ul>
|
38
38
|
<li>...</li>
|
data/lib/test-unit-ext.rb
CHANGED
@@ -8,6 +8,6 @@ require "test-unit-ext/always-show-result"
|
|
8
8
|
require "test-unit-ext/priority"
|
9
9
|
require "test-unit-ext/backtrace-filter"
|
10
10
|
require "test-unit-ext/long-display-for-emacs"
|
11
|
-
require "test-unit-ext/
|
11
|
+
require "test-unit-ext/attributes"
|
12
12
|
require "test-unit-ext/xml-report"
|
13
13
|
require "test-unit-ext/assertions"
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
|
3
|
+
module Test
|
4
|
+
module Unit
|
5
|
+
class TestCase
|
6
|
+
class << self
|
7
|
+
alias_method :method_added_without_attributes, :method_added
|
8
|
+
def method_added(name)
|
9
|
+
method_added_without_attributes(name)
|
10
|
+
if defined?(@current_attributes)
|
11
|
+
set_attributes(name, @current_attributes)
|
12
|
+
@current_attributes = {}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def attribute(name, value, *tests)
|
17
|
+
@current_attributes ||= {}
|
18
|
+
if tests.empty?
|
19
|
+
@current_attributes[name] = value
|
20
|
+
else
|
21
|
+
tests.each do |test|
|
22
|
+
set_attribute(test, {name => value})
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def bug(value, *tests)
|
28
|
+
attribute(:bug, value, *tests)
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_attributes(test_name, attributes)
|
32
|
+
return if attributes.empty?
|
33
|
+
test_name = normalize_test_name(test_name)
|
34
|
+
@attributes ||= {}
|
35
|
+
@attributes[test_name] ||= {}
|
36
|
+
@attributes[test_name] = @attributes[test_name].merge(attributes)
|
37
|
+
end
|
38
|
+
|
39
|
+
def attributes(test_name)
|
40
|
+
test_name = normalize_test_name(test_name)
|
41
|
+
@attributes ||= {}
|
42
|
+
@attributes[test_name]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
alias_method :run_without_attributes, :run
|
47
|
+
def run(result, &block)
|
48
|
+
run_without_attributes(TestResultAttributesSupport.new(result, self),
|
49
|
+
&block)
|
50
|
+
end
|
51
|
+
|
52
|
+
def attributes
|
53
|
+
self.class.attributes(@method_name) || {}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class TestResultAttributesSupport
|
58
|
+
def initialize(result, test)
|
59
|
+
@result = result
|
60
|
+
@test = test
|
61
|
+
end
|
62
|
+
|
63
|
+
def add_failure(failure)
|
64
|
+
failure.attributes = @test.attributes
|
65
|
+
method_missing(:add_failure, failure)
|
66
|
+
end
|
67
|
+
|
68
|
+
def add_error(error)
|
69
|
+
error.attributes = @test.attributes
|
70
|
+
method_missing(:add_error, error)
|
71
|
+
end
|
72
|
+
|
73
|
+
def method_missing(name, *args, &block)
|
74
|
+
@result.send(name, *args, &block)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
module AttributesFormatter
|
79
|
+
private
|
80
|
+
def format_attributes
|
81
|
+
return '' if attributes.empty?
|
82
|
+
attributes.collect do |key, value|
|
83
|
+
" #{key}: #{value}"
|
84
|
+
end.join("\n") + "\n"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
class Failure
|
89
|
+
include AttributesFormatter
|
90
|
+
|
91
|
+
attr_accessor :attributes
|
92
|
+
|
93
|
+
alias_method :long_display_without_attributes, :long_display
|
94
|
+
def long_display
|
95
|
+
test_name_re = Regexp.escape(@test_name)
|
96
|
+
long_display_without_attributes.sub(/(^#{test_name_re}.*\n)/,
|
97
|
+
"\\1#{format_attributes}")
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
class Error
|
102
|
+
include AttributesFormatter
|
103
|
+
|
104
|
+
attr_accessor :attributes
|
105
|
+
|
106
|
+
alias_method :long_display_without_attributes, :long_display
|
107
|
+
def long_display
|
108
|
+
test_name_re = Regexp.escape(@test_name)
|
109
|
+
long_display_without_attributes.sub(/(^#{test_name_re}:\n)/,
|
110
|
+
"\\1#{format_attributes}")
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "test/unit"
|
2
2
|
|
3
3
|
require "fileutils"
|
4
|
+
require "tmpdir"
|
4
5
|
|
5
6
|
module Test
|
6
7
|
module Unit
|
@@ -111,18 +112,20 @@ module Test
|
|
111
112
|
|
112
113
|
def result_dir
|
113
114
|
components = [".test-result", self.class.name, @method_name.to_s]
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
115
|
+
parent_directories = [File.dirname($0),
|
116
|
+
File.join(File.dirname(__FILE__), ".."),
|
117
|
+
Dir.pwd,
|
118
|
+
File.join(Dir.tmpdir, Process.uid.to_s)]
|
119
|
+
parent_directories.each do |parent_directory|
|
120
|
+
dir = File.expand_path(File.join(parent_directory, *components))
|
121
|
+
begin
|
122
|
+
FileUtils.mkdir_p(dir)
|
123
|
+
return dir
|
124
|
+
rescue Errno::EACCES
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
raise Errno::EACCES, parent_directories.join(", ")
|
126
129
|
end
|
127
130
|
|
128
131
|
def passed_file
|
@@ -11,37 +11,37 @@ module Test
|
|
11
11
|
include ERB::Util
|
12
12
|
|
13
13
|
def to_xml
|
14
|
-
<<-XML.gsub(/\s*(\n
|
15
|
-
<
|
14
|
+
<<-XML.gsub(/\s*(\n <\/test>|\n<\/result>)/m, "\\1")
|
15
|
+
<result>
|
16
16
|
<test_case>
|
17
17
|
<name>#{h(@test.class.name)}</name>
|
18
18
|
<description/>
|
19
19
|
</test_case>
|
20
|
-
<
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
</
|
20
|
+
<test>
|
21
|
+
<name>#{h(@test.method_name)}</name>
|
22
|
+
<description/>
|
23
|
+
#{attributes_xml}
|
24
|
+
</test>
|
25
|
+
<status>#{h(status_name)}</status>
|
26
|
+
<detail>#{h(message)}</detail>
|
27
|
+
<elapsed>#{h(elapsed_time)}</elapsed>
|
28
28
|
#{backtrace_xml}
|
29
|
-
</
|
29
|
+
</result>
|
30
30
|
XML
|
31
31
|
end
|
32
32
|
|
33
33
|
private
|
34
|
-
def
|
35
|
-
return "" if @test.
|
36
|
-
|
34
|
+
def attributes_xml
|
35
|
+
return "" if @test.attributes.empty?
|
36
|
+
attributes = @test.attributes.collect do |key, value|
|
37
37
|
<<-XML
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
<attribute>
|
39
|
+
<name>#{h(key)}</name>
|
40
|
+
<value>#{h(value)}</value>
|
41
|
+
</attribute>
|
42
42
|
XML
|
43
43
|
end
|
44
|
-
"
|
44
|
+
" <attributes>\n#{attributes.join} </attributes>"
|
45
45
|
end
|
46
46
|
|
47
47
|
def backtrace_xml
|
@@ -180,9 +180,9 @@ XML
|
|
180
180
|
end
|
181
181
|
|
182
182
|
def to_xml
|
183
|
-
return "<
|
183
|
+
return "<report/>" if @logs.empty?
|
184
184
|
xml = @logs.collect {|log| log.to_xml.gsub(/^/, " ")}.join
|
185
|
-
"<
|
185
|
+
"<report>\n#{xml}</report>\n"
|
186
186
|
end
|
187
187
|
end
|
188
188
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test-unit-ext'
|
2
2
|
|
3
|
-
class
|
3
|
+
class TestAttributes < Test::Unit::TestCase
|
4
4
|
class TestStack < Test::Unit::TestCase
|
5
5
|
class << self
|
6
6
|
def suite
|
@@ -34,19 +34,19 @@ class TestMetadata < Test::Unit::TestCase
|
|
34
34
|
@stack = Stack.new
|
35
35
|
end
|
36
36
|
|
37
|
-
|
37
|
+
attribute :category, :accessor
|
38
38
|
def test_peek
|
39
39
|
@stack.push(1)
|
40
40
|
@stack.push(2)
|
41
41
|
assert_equal(2, @stack.peek)
|
42
42
|
end
|
43
43
|
|
44
|
-
|
44
|
+
attribute :bug, 1234
|
45
45
|
def test_bug_1234
|
46
46
|
assert_equal(0, @stack.size)
|
47
47
|
end
|
48
48
|
|
49
|
-
def
|
49
|
+
def test_no_attributes
|
50
50
|
assert(@stack.empty?)
|
51
51
|
@stack.push(1)
|
52
52
|
assert(!@stack.empty?)
|
@@ -54,21 +54,21 @@ class TestMetadata < Test::Unit::TestCase
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
def
|
57
|
+
def test_set_attributes
|
58
58
|
test_for_bug_1234 = TestStack.new("test_bug_1234")
|
59
|
-
assert_equal({:bug => 1234}, test_for_bug_1234.
|
59
|
+
assert_equal({:bug => 1234}, test_for_bug_1234.attributes)
|
60
60
|
|
61
|
-
|
62
|
-
assert_equal({},
|
61
|
+
test_no_attributes = TestStack.new("test_no_attributes")
|
62
|
+
assert_equal({}, test_no_attributes.attributes)
|
63
63
|
end
|
64
64
|
|
65
|
-
def
|
65
|
+
def test_show_attributes
|
66
66
|
assert_stack_size_line = search_line('assert_equal(0, @stack.size)')
|
67
67
|
assert_peek_line = search_line('assert_equal(2, @stack.peek)')
|
68
68
|
first_arg_end_line = search_line("\"+ 11\"],")
|
69
|
-
method_name = "
|
69
|
+
method_name = "test_show_attributes"
|
70
70
|
assert_result(["Failure:\n" \
|
71
|
-
"test_peek(
|
71
|
+
"test_peek(TestAttributes::TestStack)\n" \
|
72
72
|
" category: accessor\n" \
|
73
73
|
"#{__FILE__}:#{assert_peek_line}:in `test_peek'\n" \
|
74
74
|
"#{__FILE__}:#{first_arg_end_line}:in `#{method_name}':\n" \
|
@@ -78,7 +78,7 @@ class TestMetadata < Test::Unit::TestCase
|
|
78
78
|
"- 2\n" \
|
79
79
|
"+ 1",
|
80
80
|
"Failure:\n" \
|
81
|
-
"test_bug_1234(
|
81
|
+
"test_bug_1234(TestAttributes::TestStack)\n" \
|
82
82
|
" bug: 1234\n" \
|
83
83
|
"#{__FILE__}:#{assert_stack_size_line}:in `test_bug_1234'\n" \
|
84
84
|
"#{__FILE__}:#{first_arg_end_line}:in `#{method_name}':\n" \
|
@@ -91,13 +91,13 @@ class TestMetadata < Test::Unit::TestCase
|
|
91
91
|
["test_peek", "test_bug_1234"])
|
92
92
|
end
|
93
93
|
|
94
|
-
def
|
94
|
+
def test_not_show_attributes
|
95
95
|
assert_line = search_line('assert_equal(1, @stack.size')
|
96
96
|
first_arg_end_line = search_line("\"+ 12\"],")
|
97
|
-
method_name = "
|
97
|
+
method_name = "test_not_show_attributes"
|
98
98
|
assert_result(["Failure:\n" \
|
99
|
-
"
|
100
|
-
"#{__FILE__}:#{assert_line}:in `
|
99
|
+
"test_no_attributes(TestAttributes::TestStack)\n" \
|
100
|
+
"#{__FILE__}:#{assert_line}:in `test_no_attributes'\n" \
|
101
101
|
"#{__FILE__}:#{first_arg_end_line}:in `#{method_name}':\n" \
|
102
102
|
"<1> expected but was\n" \
|
103
103
|
"<12>.\n" \
|
@@ -105,7 +105,7 @@ class TestMetadata < Test::Unit::TestCase
|
|
105
105
|
"- 1\n" \
|
106
106
|
"+ 12"],
|
107
107
|
[],
|
108
|
-
["
|
108
|
+
["test_no_attributes"])
|
109
109
|
end
|
110
110
|
|
111
111
|
private
|
data/test/test_xml_report.rb
CHANGED
@@ -28,27 +28,27 @@ class TestXMLReport < Test::Unit::TestCase
|
|
28
28
|
include ERB::Util
|
29
29
|
|
30
30
|
def test_empty_test
|
31
|
-
assert_xml("<
|
31
|
+
assert_xml("<report/>", suite)
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_success_result
|
35
35
|
elapsed = "0.001"
|
36
36
|
assert_xml(<<-XML, suite([TestCase.new("_test_success")]), elapsed)
|
37
|
-
<
|
38
|
-
<
|
37
|
+
<report>
|
38
|
+
<result>
|
39
39
|
<test_case>
|
40
40
|
<name>TestXMLReport::TestCase</name>
|
41
41
|
<description/>
|
42
42
|
</test_case>
|
43
|
-
<
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
</
|
50
|
-
</
|
51
|
-
</
|
43
|
+
<test>
|
44
|
+
<name>_test_success</name>
|
45
|
+
<description/>
|
46
|
+
</test>
|
47
|
+
<status>success</status>
|
48
|
+
<detail></detail>
|
49
|
+
<elapsed>#{elapsed}</elapsed>
|
50
|
+
</result>
|
51
|
+
</report>
|
52
52
|
XML
|
53
53
|
end
|
54
54
|
|
@@ -56,25 +56,25 @@ XML
|
|
56
56
|
elapsed = "0.001"
|
57
57
|
backtrace_line = __LINE__ + 1
|
58
58
|
assert_xml(<<-XML, suite([TestCase.new("_test_failure")]), elapsed)
|
59
|
-
<
|
60
|
-
<
|
59
|
+
<report>
|
60
|
+
<result>
|
61
61
|
<test_case>
|
62
62
|
<name>TestXMLReport::TestCase</name>
|
63
63
|
<description/>
|
64
64
|
</test_case>
|
65
|
-
<
|
66
|
-
|
67
|
-
|
68
|
-
<
|
69
|
-
<
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
</
|
65
|
+
<test>
|
66
|
+
<name>_test_failure</name>
|
67
|
+
<description/>
|
68
|
+
<attributes>
|
69
|
+
<attribute>
|
70
|
+
<name>bug</name>
|
71
|
+
<value>1234</value>
|
72
|
+
</attribute>
|
73
|
+
</attributes>
|
74
|
+
</test>
|
75
|
+
<status>failure</status>
|
76
|
+
<detail><false> is not true.</detail>
|
77
|
+
<elapsed>#{elapsed}</elapsed>
|
78
78
|
<backtrace>
|
79
79
|
<entry>
|
80
80
|
<file>#{__FILE__}</file>
|
@@ -92,8 +92,8 @@ XML
|
|
92
92
|
<info>in `test_failure_result'</info>
|
93
93
|
</entry>
|
94
94
|
</backtrace>
|
95
|
-
</
|
96
|
-
</
|
95
|
+
</result>
|
96
|
+
</report>
|
97
97
|
XML
|
98
98
|
end
|
99
99
|
|
@@ -104,19 +104,19 @@ XML
|
|
104
104
|
elapsed = "0.001"
|
105
105
|
backtrace_line = __LINE__ + 1
|
106
106
|
assert_xml(<<-XML, suite([test]), elapsed)
|
107
|
-
<
|
108
|
-
<
|
107
|
+
<report>
|
108
|
+
<result>
|
109
109
|
<test_case>
|
110
110
|
<name>TestXMLReport::TestCase</name>
|
111
111
|
<description/>
|
112
112
|
</test_case>
|
113
|
-
<
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
</
|
113
|
+
<test>
|
114
|
+
<name>_test_error</name>
|
115
|
+
<description/>
|
116
|
+
</test>
|
117
|
+
<status>error</status>
|
118
|
+
<detail>#{h(detail)}</detail>
|
119
|
+
<elapsed>#{elapsed}</elapsed>
|
120
120
|
<backtrace>
|
121
121
|
<entry>
|
122
122
|
<file>#{__FILE__}</file>
|
@@ -134,8 +134,8 @@ XML
|
|
134
134
|
<info>in `test_error_result'</info>
|
135
135
|
</entry>
|
136
136
|
</backtrace>
|
137
|
-
</
|
138
|
-
</
|
137
|
+
</result>
|
138
|
+
</report>
|
139
139
|
XML
|
140
140
|
end
|
141
141
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-unit-ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-03-
|
12
|
+
date: 2008-03-10 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -20,8 +20,11 @@ executables: []
|
|
20
20
|
|
21
21
|
extensions: []
|
22
22
|
|
23
|
-
extra_rdoc_files:
|
24
|
-
|
23
|
+
extra_rdoc_files:
|
24
|
+
- NEWS.en
|
25
|
+
- NEWS.ja
|
26
|
+
- README.en
|
27
|
+
- README.ja
|
25
28
|
files:
|
26
29
|
- NEWS.en
|
27
30
|
- NEWS.ja
|
@@ -38,27 +41,27 @@ files:
|
|
38
41
|
- lib/test-unit-ext.rb
|
39
42
|
- lib/test-unit-ext/always-show-result.rb
|
40
43
|
- lib/test-unit-ext/assertions.rb
|
44
|
+
- lib/test-unit-ext/attributes.rb
|
41
45
|
- lib/test-unit-ext/backtrace-filter.rb
|
42
46
|
- lib/test-unit-ext/color.rb
|
43
47
|
- lib/test-unit-ext/colorized-runner.rb
|
44
48
|
- lib/test-unit-ext/diff.rb
|
45
49
|
- lib/test-unit-ext/long-display-for-emacs.rb
|
46
|
-
- lib/test-unit-ext/metadata.rb
|
47
50
|
- lib/test-unit-ext/priority.rb
|
48
51
|
- lib/test-unit-ext/version.rb
|
49
52
|
- lib/test-unit-ext/xml-report.rb
|
50
53
|
- misc/rd2html.rb
|
51
54
|
- test/run-test.rb
|
55
|
+
- test/test_attributes.rb
|
52
56
|
- test/test_color.rb
|
53
57
|
- test/test_diff.rb
|
54
|
-
- test/test_metadata.rb
|
55
58
|
- test/test_xml_report.rb
|
56
59
|
has_rdoc: true
|
57
60
|
homepage: http://test-unit-ext.rubyforge.org/
|
58
61
|
post_install_message:
|
59
62
|
rdoc_options:
|
60
63
|
- --main
|
61
|
-
- README.
|
64
|
+
- README.en
|
62
65
|
require_paths:
|
63
66
|
- lib
|
64
67
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -82,6 +85,6 @@ specification_version: 2
|
|
82
85
|
summary: TestUnitExt extends the standard Test::Unit.
|
83
86
|
test_files:
|
84
87
|
- test/test_diff.rb
|
85
|
-
- test/test_metadata.rb
|
86
88
|
- test/test_color.rb
|
87
89
|
- test/test_xml_report.rb
|
90
|
+
- test/test_attributes.rb
|
@@ -1,111 +0,0 @@
|
|
1
|
-
require "test/unit"
|
2
|
-
|
3
|
-
module Test
|
4
|
-
module Unit
|
5
|
-
class TestCase
|
6
|
-
class << self
|
7
|
-
alias_method :method_added_without_metadata, :method_added
|
8
|
-
def method_added(name)
|
9
|
-
method_added_without_metadata(name)
|
10
|
-
if defined?(@current_metadata)
|
11
|
-
set_metadata(name, @current_metadata)
|
12
|
-
@current_metadata = {}
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def metadata(name, value, *tests)
|
17
|
-
@current_metadata ||= {}
|
18
|
-
if tests.empty?
|
19
|
-
@current_metadata[name] = value
|
20
|
-
else
|
21
|
-
tests.each do |test|
|
22
|
-
set_metadata(test, {name => value})
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def bug(value, *tests)
|
28
|
-
metadata(:bug, value, *tests)
|
29
|
-
end
|
30
|
-
|
31
|
-
def set_metadata(test_name, metadata)
|
32
|
-
return if metadata.empty?
|
33
|
-
test_name = normalize_test_name(test_name)
|
34
|
-
@metadata ||= {}
|
35
|
-
@metadata[test_name] ||= {}
|
36
|
-
@metadata[test_name] = @metadata[test_name].merge(metadata)
|
37
|
-
end
|
38
|
-
|
39
|
-
def get_metadata(test_name)
|
40
|
-
test_name = normalize_test_name(test_name)
|
41
|
-
@metadata ||= {}
|
42
|
-
@metadata[test_name]
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
alias_method :run_without_metadata, :run
|
47
|
-
def run(result, &block)
|
48
|
-
run_without_metadata(TestResultMetadataSupport.new(result, self), &block)
|
49
|
-
end
|
50
|
-
|
51
|
-
def metadata
|
52
|
-
self.class.get_metadata(@method_name) || {}
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
class TestResultMetadataSupport
|
57
|
-
def initialize(result, test)
|
58
|
-
@result = result
|
59
|
-
@test = test
|
60
|
-
end
|
61
|
-
|
62
|
-
def add_failure(failure)
|
63
|
-
failure.metadata = @test.metadata
|
64
|
-
method_missing(:add_failure, failure)
|
65
|
-
end
|
66
|
-
|
67
|
-
def add_error(error)
|
68
|
-
error.metadata = @test.metadata
|
69
|
-
method_missing(:add_error, error)
|
70
|
-
end
|
71
|
-
|
72
|
-
def method_missing(name, *args, &block)
|
73
|
-
@result.send(name, *args, &block)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
module MetadataFormatter
|
78
|
-
private
|
79
|
-
def format_metadata
|
80
|
-
return '' if metadata.empty?
|
81
|
-
metadata.collect do |key, value|
|
82
|
-
" #{key}: #{value}"
|
83
|
-
end.join("\n") + "\n"
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
class Failure
|
88
|
-
include MetadataFormatter
|
89
|
-
|
90
|
-
attr_accessor :metadata
|
91
|
-
|
92
|
-
alias_method :long_display_without_metadata, :long_display
|
93
|
-
def long_display
|
94
|
-
long_display_without_metadata.sub(/(^#{Regexp.escape(@test_name)}.*\n)/,
|
95
|
-
"\\1#{format_metadata}")
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
class Error
|
100
|
-
include MetadataFormatter
|
101
|
-
|
102
|
-
attr_accessor :metadata
|
103
|
-
|
104
|
-
alias_method :long_display_without_metadata, :long_display
|
105
|
-
def long_display
|
106
|
-
long_display_without_metadata.sub(/(^#{Regexp.escape(@test_name)}:\n)/,
|
107
|
-
"\\1#{format_metadata}")
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|