require "cgi"
module Teaspoon
module Formatters
class JunitFormatter < Base
protected
def log_runner(result)
log_line(%Q{})
log_line(%Q{})
log_line(%Q{})
end
def log_suite(result)
log_end_suite
log_line(%Q{})
end
def log_passing_spec(result)
log_junit_spec(suite: result.suite, label: result.label)
end
def log_pending_spec(result)
log_junit_spec(suite: result.suite, label: result.label) do
log_line(%Q{ })
end
end
def log_failing_spec(result)
log_junit_spec(suite: result.suite, label: result.label) do
log_line(%Q{ #{cdata(result.message)}})
end
end
def log_result(result)
log_end_suite
end
def log_coverage(message)
log_line(%Q{\n#{cdata(message)}\n})
end
def log_threshold_failure(message)
log_line(%Q{})
log_junit_spec(suite: "Coverage thresholds", label: "were not met") do
log_line(%Q{ #{cdata(message)}})
end
log_line(%Q{})
end
def log_complete(failure_count)
log_line(%Q{\n})
end
private
def log_end_suite
log_line(%Q{}) if @last_suite
end
def log_junit_spec(opts, &block)
log_line(%Q{})
yield if block_given?
log_line(%Q{#{cdata(@stdout)}}) unless @stdout.blank?
log_line(%Q{})
end
def escape(str)
CGI::escapeHTML(str)
end
def cdata(str)
"\n\n"
end
end
end
end