Method: PDK::Report::Event#to_junit

Defined in:
lib/pdk/report/event.rb

#to_junitREXML::Element

Renders the event as a JUnit XML testcase.

Returns:

  • (REXML::Element)

    The rendered event.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/pdk/report/event.rb', line 139

def to_junit
  require 'rexml/document'

  testcase = REXML::Element.new('testcase')
  testcase.attributes['classname'] = [source, test].compact.join('.')
  testcase.attributes['name'] = [file, line, column].compact.join(':')
  testcase.attributes['time'] = 0

  if failure?
    failure = REXML::Element.new('failure')
    failure.attributes['type'] = severity
    failure.attributes['message'] = message
    failure.text = to_text
    testcase.elements << failure
  elsif skipped?
    testcase.add_element('skipped')
  end

  testcase
end