## Exposes functionality to export results of a test run in JUnit XML format. ## ## This class exposes two methods for exporting GUT test results to XML. ## One returns a string representing the XML, and the other writes it to ## a file. var _strutils := GutStringUtils.new() var _exporter = GutUtils.ResultExporter.new() func _wrap_cdata(content) -> String: return "" func _add_attr(name, value) -> String: return str(name, '="', value, '" ') func _export_test_result(test: Dictionary) -> String: var to_return := '' # Right now the pending and failure messages won't fit in the message # attribute because they can span multiple lines and need to be escaped. if(test.status == 'pending'): var skip_tag := str("", _wrap_cdata(test.pending[0]), "") to_return += skip_tag elif(test.status == 'fail'): var fail_tag := str("", _wrap_cdata(test.failing[0]), "") to_return += fail_tag return to_return func _export_tests(script_result: Dictionary, classname: String) -> String: var to_return := "" for test_name: String in script_result.keys(): var test: Dictionary = script_result[test_name] var assert_count = test.passing.size() + test.failing.size() to_return += " float: var to_return := 0.0 for test: Dictionary in script_result.values(): to_return += test.time_taken return to_return func _export_scripts(exp_results: Dictionary) -> String: var to_return := "" for script_path: String in exp_results.test_scripts.scripts.keys(): var s: Dictionary = exp_results.test_scripts.scripts[script_path] to_return += " String: var exp_results: Dictionary = _exporter.get_results_dictionary(gut) var to_return := '' + "\n" to_return += ' int: var xml := get_results_xml(gut) var f_result: int = GutUtils.write_file(path, xml) if(f_result != OK): var msg := str("Error: ", f_result, ". Could not create export file ", path) GutUtils.get_logger().error(msg) return f_result