Class: Test::Reporters::Tap
Overview
TAP version 13 stream. The plan follows execution so case outcomes count.
Instance Attribute Summary
Attributes inherited from Abstract
#runner
Instance Method Summary
collapse
Methods inherited from Abstract
#begin_case, #begin_test, #end_case, #end_test, inherited, registry
Constructor Details
#initialize(runner, output: $stdout) ⇒ Tap
Returns a new instance of Tap.
4
5
6
7
|
# File 'lib/rubytest/format/tap.rb', line 4
def initialize(runner, output: $stdout)
super(runner)
@output = output
end
|
Instance Method Details
#begin_suite(suite) ⇒ Object
13
14
15
16
|
# File 'lib/rubytest/format/tap.rb', line 13
def begin_suite(suite)
@index = 0
@output.puts 'TAP version 13'
end
|
#capture_output? ⇒ Boolean
9
10
11
|
# File 'lib/rubytest/format/tap.rb', line 9
def capture_output?
true
end
|
#finish(summary) ⇒ Object
40
41
42
|
# File 'lib/rubytest/format/tap.rb', line 40
def finish(summary)
@output.puts summary.total.zero? ? '1..0 # SKIP No tests were run' : "1..#{summary.total}"
end
|
#record(result) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/rubytest/format/tap.rb', line 18
def record(result)
@index += 1
label = single_line(result.test.to_s)
line = "#{[:pass, :skip].include?(result.status) ? 'ok' : 'not ok'} #{@index} - #{label}"
case result.status
when :skip
line << " # SKIP #{single_line(result.reason)}"
when :todo
line << " # TODO #{single_line(result.exception&.message)}"
end
@output.puts line.rstrip
if [:fail, :error].include?(result.status)
result.exceptions.each do |exception|
diagnostic("#{exception.class}: #{exception.message}")
diagnostic(exception.backtrace&.first) if exception.backtrace&.first
end
end
result.stdout.each_line { |line| diagnostic("stdout: #{line}") }
result.stderr.each_line { |line| diagnostic("stderr: #{line}") }
end
|