class Strut::ReportJUnitFormatter

Public Instance Methods

add_element_for_testcase(element, testcase, message, type) click to toggle source
# File lib/strut/report_junit_formatter.rb, line 41
def add_element_for_testcase(element, testcase, message, type)
  node = testcase.add_element(element)
  node.attributes["message"] = message
  node.attributes["type"] = type
end
add_error_for_testcase(message, testcase) click to toggle source
# File lib/strut/report_junit_formatter.rb, line 37
def add_error_for_testcase(message, testcase)
  add_element_for_testcase("error", testcase, message, "exception")
end
add_failure_for_testcase(message, testcase) click to toggle source
# File lib/strut/report_junit_formatter.rb, line 33
def add_failure_for_testcase(message, testcase)
  add_element_for_testcase("failure", testcase, message, "assert")
end
add_result_for_testcase(scenario, testcase) click to toggle source
# File lib/strut/report_junit_formatter.rb, line 25
def add_result_for_testcase(scenario, testcase)
  if scenario.result == SCENARIO_FAIL
    add_failure_for_testcase(scenario.message, testcase)
  elsif scenario.result == SCENARIO_ERROR
    add_error_for_testcase(scenario.message, testcase)
  end
end
add_testcase_for_scenario(scenario, testsuite) click to toggle source
# File lib/strut/report_junit_formatter.rb, line 17
def add_testcase_for_scenario(scenario, testsuite)
  testcase = testsuite.add_element("testcase")
  testcase.attributes["name"] = scenario.name
  testcase.attributes["time"] = scenario.time
  testcase.attributes["classname"] = "swagger"
  add_result_for_testcase(scenario, testcase)
end
add_testsuite(results, doc) click to toggle source
# File lib/strut/report_junit_formatter.rb, line 10
def add_testsuite(results, doc)
  testsuite = doc.add_element("testsuite")
  results.each do |scenario|
    add_testcase_for_scenario(scenario, testsuite)
  end
end
format(report) click to toggle source
# File lib/strut/report_junit_formatter.rb, line 3
def format(report)
  doc = REXML::Document.new("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
  results = report.scenario_results
  add_testsuite(results, doc)
  doc.to_s
end