Commit 113258a9 113258a9e8e57dc296944c706a324a2d69293d1a by Laurent Jouanneau Committed by Nicolas Perriault

Fix XUnit output with Gecko

the toString() function is not called by gecko because a DOMNode
does not inherits from Object. We should call a specific function
to serialize the content of the XML.
1 parent dc4dbf15
......@@ -1619,7 +1619,7 @@ Tester.prototype.saveResults = function saveResults(filepath) {
var exporter = require('xunit').create();
exporter.setResults(this.suiteResults);
try {
fs.write(filepath, exporter.getXML(), 'w');
fs.write(filepath, exporter.getSerializedXML(), 'w');
this.casper.echo(f('Result log stored in %s', filepath), 'INFO', 80);
} catch (e) {
this.casper.echo(f('Unable to write results to %s: %s', filepath, e), 'ERROR', 80);
......
......@@ -82,10 +82,6 @@ function XUnitExporter() {
"use strict";
this.results = undefined;
this._xml = utils.node('testsuites');
this._xml.toString = function toString() {
var serializer = new XMLSerializer();
return '<?xml version="1.0" encoding="UTF-8"?>' + serializer.serializeToString(this);
};
}
exports.XUnitExporter = XUnitExporter;
......@@ -158,6 +154,16 @@ XUnitExporter.prototype.getXML = function getXML() {
};
/**
* Retrieves generated Xunit XML
*
* @return string
*/
XUnitExporter.prototype.getSerializedXML = function getSerializedXML(xml) {
var serializer = new XMLSerializer();
return '<?xml version="1.0" encoding="UTF-8"?>' + serializer.serializeToString(this.getXML());
}
/**
* Sets test results.
*
* @param TestSuite results
......