Class: Tapout::Reporters::Html
Overview
HTML Test Reporter
This reporter is rather simplistic and rough at this point –in needs of some TLC. – TODO: Make this more like a microformat and add timer info. ++
Constant Summary
Constants inherited
from Abstract
Abstract::INTERNALS
Instance Method Summary
collapse
Methods inherited from Abstract
#<<, #backtrace, #backtrace_snippets, #backtrace_snippets_chain, #captured_output, #captured_output?, #captured_stderr, #captured_stderr?, #captured_stdout, #captured_stdout?, #clean_backtrace, #code_snippet, #complete_cases, #config, #count_tally, #duration, #exit_code, #finalize, #finish_case, #finish_test, #format_snippet_array, #handle, inherited, #initialize, #note, #parse_backtrace, #parse_source_location, #source, #tally, #tally_message, #time_tally
Instance Method Details
#error(entry) ⇒ Object
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/tapout/reporters/html_reporter.rb', line 85
def error(entry)
e = entry['exception']
puts %[<li class="error">]
puts "ERROR "
puts e['message'].to_s
puts "<pre>"
puts clean_backtrace(e['backtrace']).join("\n")
puts "</pre>"
puts %[</li>]
end
|
#fail(entry) ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/tapout/reporters/html_reporter.rb', line 72
def fail(entry)
e = entry['exception']
puts %[<li class="fail">]
puts "FAIL #{e['message']}"
puts "<pre>"
puts clean_backtrace(e['backtrace']).join("\n")
puts "</pre>"
puts %[</li>]
end
|
#finish_suite(entry) ⇒ Object
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
# File 'lib/tapout/reporters/html_reporter.rb', line 119
def finish_suite(entry)
puts ""
puts %[<div class="tally">]
puts tally_message(entry)
puts %[</div>]
puts ""
puts ""
puts %[<div class="footer">]
puts %[Generated by <a href="http://rubyworks.github.com/tapout">TAPOUT</a>]
puts %[on #{Time.now}.]
puts %[</div>]
puts ""
puts %[</div>]
puts %[</div>]
puts ""
puts %[</body>]
puts %[</html>]
end
|
#omit(entry) ⇒ Object
109
110
111
112
113
114
115
116
|
# File 'lib/tapout/reporters/html_reporter.rb', line 109
def omit(entry)
e = entry['exception']
puts %[<li class="omit">]
puts "OMIT "
puts e['message'].to_s
puts %[</li>]
end
|
#pass(entry) ⇒ Object
65
66
67
68
69
|
# File 'lib/tapout/reporters/html_reporter.rb', line 65
def pass(entry)
puts %[<li class="pass">]
puts "%s %s" % [ "PASS", entry['label'] ]
puts %[</li>]
end
|
#start_case(entry) ⇒ Object
44
45
46
47
48
49
50
51
52
|
# File 'lib/tapout/reporters/html_reporter.rb', line 44
def start_case(entry)
body = []
puts "<h2>"
puts entry['label']
puts "</h2>"
puts body.join("\n")
end
|
#start_suite(entry) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/tapout/reporters/html_reporter.rb', line 15
def start_suite(entry)
timer_reset
puts %[<html>]
puts %[<head>]
puts %[<title>Test Report</title>]
puts %[ <style>]
puts %[ html{ background: #fff; margin: 0; padding: 0; font-family: helvetica; }]
puts %[ body{ margin: 0; padding: 0;}]
puts %[ h3{color:#555;}]
puts %[ #main{ margin: 0 auto; color: #110; width: 600px; ]
puts %[ border-right: 1px solid #ddd; border-left: 1px solid #ddd; ]
puts %[ padding: 10px 30px; width: 500px; } ]
puts %[ .title{ color: gold; font-size: 22px; font-weight: bold; ]
puts %[ font-family: courier; margin-bottom: -15px;}]
puts %[ .tally{ font-weight: bold; margin-bottom: 10px; }]
puts %[ .omit{ color: cyan; }]
puts %[ .pass{ color: green; }]
puts %[ .fail{ color: red; }]
puts %[ .footer{ font-size: 0.7em; color: #666; margin: 20px 0; }]
puts %[ </style>]
puts %[</head>]
puts %[<body>]
puts %[<div id="main">]
puts %[<div class="title">R U B Y - T E S T</div>]
puts %[<h1>Test Report</h1>]
end
|
#start_test(entry) ⇒ Object
55
56
57
58
59
60
61
62
|
# File 'lib/tapout/reporters/html_reporter.rb', line 55
def start_test(entry)
if subtext = entry['subtext']
if @subtext != subtext
@subtext = subtext
puts "<h3>#{subtext}</h3>"
end
end
end
|
#timer ⇒ Object
141
142
143
144
145
|
# File 'lib/tapout/reporters/html_reporter.rb', line 141
def timer
secs = Time.now - @time
@time = Time.now
return "%0.5fs" % [secs.to_s]
end
|
#timer_reset ⇒ Object
148
149
150
|
# File 'lib/tapout/reporters/html_reporter.rb', line 148
def timer_reset
@time = Time.now
end
|
#todo(entry) ⇒ Object
99
100
101
102
103
104
105
106
|
# File 'lib/tapout/reporters/html_reporter.rb', line 99
def todo(entry)
e = entry['exception']
puts %[<li class="pending">]
puts "TODO "
puts e['message'].to_s
puts %[</li>]
end
|