class Webspicy::Tester::Reporter::JunitXmlFile
Constants
- TPL
Attributes
template_data[R]
timer_all[R]
timer_specification[R]
timer_testcase[R]
Public Class Methods
new(path_or_io = STDOUT)
click to toggle source
# File lib/webspicy/tester/reporter/junit_xml_file.rb, line 50 def initialize(path_or_io = STDOUT) @path_or_io = path_or_io path_or_io.parent.mkdir_p if path_or_io.is_a?(Path) end
Public Instance Methods
after_all()
click to toggle source
# File lib/webspicy/tester/reporter/junit_xml_file.rb, line 65 def after_all template_data.time = Time.now - timer_all end
before_all()
click to toggle source
# File lib/webspicy/tester/reporter/junit_xml_file.rb, line 57 def before_all @timer_all = Time.now @template_data = OpenStruct.new({ counts: Hash.new{|h,k| h[k] = 0 }, testsuites: [] }) end
before_specification()
click to toggle source
# File lib/webspicy/tester/reporter/junit_xml_file.rb, line 69 def before_specification @timer_specification = Time.now template_data.testsuites << OpenStruct.new({ :name => specification.name, :counts => Hash.new{|h,k| h[k] = 0 }, :testcases => [] }) end
before_test_case()
click to toggle source
# File lib/webspicy/tester/reporter/junit_xml_file.rb, line 95 def before_test_case @timer_testcase = Time.now template_data.testsuites[-1].testcases << OpenStruct.new({ :name => test_case.description, :assert => test_case.assert.length, :classname => test_case.class.name.to_s.gsub(/::/, "."), :failures => [], :errors => [], }) template_data.counts[:total] += 1 template_data.testsuites[-1].counts[:total] += 1 end
check_error(check, ex)
click to toggle source
# File lib/webspicy/tester/reporter/junit_xml_file.rb, line 121 def check_error(check, ex) template_data.testsuites[-1].testcases[-1].errors << OpenStruct.new({ :type => check.class.name, :message => ex.message }) template_data.counts[:errors] += 1 template_data.testsuites[-1].counts[:errors] += 1 end
check_failure(check, ex)
click to toggle source
# File lib/webspicy/tester/reporter/junit_xml_file.rb, line 112 def check_failure(check, ex) template_data.testsuites[-1].testcases[-1].failures << OpenStruct.new({ :type => check.class.name, :message => ex.message }) template_data.counts[:failures] += 1 template_data.testsuites[-1].counts[:failures] += 1 end
report()
click to toggle source
# File lib/webspicy/tester/reporter/junit_xml_file.rb, line 130 def report require 'mustache' with_io do |io| io << Mustache.render(TPL, template_data) end end
spec_file_error(e)
click to toggle source
# File lib/webspicy/tester/reporter/junit_xml_file.rb, line 82 def spec_file_error(e) template_data.testsuites[-1].testcases << OpenStruct.new({ :name => "Specification can be loaded", :assert => 1, :classname => "Webspicy.Specification", :failures => [], :errors => [OpenStruct.new({ :type => e.class, :message => e.message })] }) end
specification_done()
click to toggle source
# File lib/webspicy/tester/reporter/junit_xml_file.rb, line 78 def specification_done template_data.testsuites[-1].time = Time.now - timer_specification end
test_case_done()
click to toggle source
# File lib/webspicy/tester/reporter/junit_xml_file.rb, line 108 def test_case_done template_data.testsuites[-1].testcases[-1].time = Time.now - timer_testcase end
Private Instance Methods
with_io(&bl)
click to toggle source
# File lib/webspicy/tester/reporter/junit_xml_file.rb, line 139 def with_io(&bl) case io = @path_or_io when IO, StringIO bl.call(io) else Path(io).open('w', &bl) end end