Commit 3bb07c1d 3bb07c1d1fcbbc20b86160d723265d62293a803c by Nicolas Perriault

added test suite duration to result bar

1 parent 8cd8607a
......@@ -1003,8 +1003,9 @@ Tester.prototype.renderResults = function renderResults(exit, status, save) {
statusText = this.options.passText;
style = 'GREEN_BAR';
}
result = f('%s %s tests executed, %d passed, %d failed.',
statusText, total, this.testResults.passed, this.testResults.failed);
result = f('%s %s tests executed in %ss, %d passed, %d failed.',
statusText, total, utils.ms2seconds(this.calculateSuiteDuration()),
this.testResults.passed, this.testResults.failed);
}
this.casper.echo(result, style, this.options.pad);
if (this.testResults.failed > 0) {
......
......@@ -495,6 +495,18 @@ function mergeObjects(origin, add) {
exports.mergeObjects = mergeObjects;
/**
* Converts milliseconds to seconds and rounds the results to 3 digits accuracy.
*
* @param Number milliseconds
* @return Number seconds
*/
function ms2seconds(milliseconds) {
"use strict";
return Math.round(milliseconds / 1000 * 1000) / 1000;
}
exports.ms2seconds = ms2seconds;
/**
* Creates an (SG|X)ML node element.
*
* @param String name The node name
......
......@@ -34,17 +34,6 @@ var utils = require('utils');
var fs = require('fs');
/**
* Returns duration in seconds, matching XUnit "standard".
*
* @param Number duration Duration in milliseconds
* @return String
*/
function format_duration(duration) {
"use strict";
return (duration / 1000).toString();
}
/**
* Generates a value for 'classname' attribute of the JUnit XML report.
*
* Uses the (relative) file name of the current casper script without file
......@@ -112,7 +101,7 @@ XUnitExporter.prototype.addSuccess = function addSuccess(classname, name, durati
name: name
});
if (duration !== undefined) {
snode.setAttribute('time', format_duration(duration));
snode.setAttribute('time', utils.ms2seconds(duration));
}
this._xml.appendChild(snode);
};
......@@ -133,7 +122,7 @@ XUnitExporter.prototype.addFailure = function addFailure(classname, name, messag
name: name
});
if (duration !== undefined) {
fnode.setAttribute('time', format_duration(duration));
fnode.setAttribute('time', utils.ms2seconds(duration));
}
var failure = utils.node('failure', {
type: type || "unknown"
......@@ -151,7 +140,7 @@ XUnitExporter.prototype.addFailure = function addFailure(classname, name, messag
XUnitExporter.prototype.setSuiteDuration = function setSuiteDuration(duration) {
"use strict";
if (!isNaN(duration)) {
this._xml.setAttribute("time", format_duration(duration));
this._xml.setAttribute("time", utils.ms2seconds(duration));
}
};
......