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) { ...@@ -1619,7 +1619,7 @@ Tester.prototype.saveResults = function saveResults(filepath) {
1619 var exporter = require('xunit').create(); 1619 var exporter = require('xunit').create();
1620 exporter.setResults(this.suiteResults); 1620 exporter.setResults(this.suiteResults);
1621 try { 1621 try {
1622 fs.write(filepath, exporter.getXML(), 'w'); 1622 fs.write(filepath, exporter.getSerializedXML(), 'w');
1623 this.casper.echo(f('Result log stored in %s', filepath), 'INFO', 80); 1623 this.casper.echo(f('Result log stored in %s', filepath), 'INFO', 80);
1624 } catch (e) { 1624 } catch (e) {
1625 this.casper.echo(f('Unable to write results to %s: %s', filepath, e), 'ERROR', 80); 1625 this.casper.echo(f('Unable to write results to %s: %s', filepath, e), 'ERROR', 80);
......
...@@ -82,10 +82,6 @@ function XUnitExporter() { ...@@ -82,10 +82,6 @@ function XUnitExporter() {
82 "use strict"; 82 "use strict";
83 this.results = undefined; 83 this.results = undefined;
84 this._xml = utils.node('testsuites'); 84 this._xml = utils.node('testsuites');
85 this._xml.toString = function toString() {
86 var serializer = new XMLSerializer();
87 return '<?xml version="1.0" encoding="UTF-8"?>' + serializer.serializeToString(this);
88 };
89 } 85 }
90 exports.XUnitExporter = XUnitExporter; 86 exports.XUnitExporter = XUnitExporter;
91 87
...@@ -158,6 +154,16 @@ XUnitExporter.prototype.getXML = function getXML() { ...@@ -158,6 +154,16 @@ XUnitExporter.prototype.getXML = function getXML() {
158 }; 154 };
159 155
160 /** 156 /**
157 * Retrieves generated Xunit XML
158 *
159 * @return string
160 */
161 XUnitExporter.prototype.getSerializedXML = function getSerializedXML(xml) {
162 var serializer = new XMLSerializer();
163 return '<?xml version="1.0" encoding="UTF-8"?>' + serializer.serializeToString(this.getXML());
164 }
165
166 /**
161 * Sets test results. 167 * Sets test results.
162 * 168 *
163 * @param TestSuite results 169 * @param TestSuite results
......