print elapsed time in summary
This commit is contained in:
parent
e8c8a0bdfd
commit
eb49fab652
|
@ -34,7 +34,8 @@ describe("TrivialNodeReporter", function() {
|
||||||
return {
|
return {
|
||||||
puts:function(str) {output += str + "\n";},
|
puts:function(str) {output += str + "\n";},
|
||||||
print:function(str) {output += str;},
|
print:function(str) {output += str;},
|
||||||
getOutput:function(){return output;}
|
getOutput:function(){return output;},
|
||||||
|
clear: function(){output = "";}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
@ -122,6 +123,48 @@ describe("TrivialNodeReporter", function() {
|
||||||
newline + prefixRed("Finished")
|
newline + prefixRed("Finished")
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("prints the elapsed time in the summary message", function(){
|
||||||
|
this.reporter.now = function(){return 1000}
|
||||||
|
this.reporter.reportRunnerStarting();
|
||||||
|
this.reporter.now = function(){return 1777}
|
||||||
|
this.reporter.reportRunnerResults(passingRun);
|
||||||
|
expect(this.fakeSys.getOutput()).toContain("0.777 seconds");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("prints round time numbers correctly", function(){
|
||||||
|
var self = this;
|
||||||
|
function run(startTime, endTime) {
|
||||||
|
self.fakeSys.clear();
|
||||||
|
self.reporter.runnerStartTime = startTime;
|
||||||
|
self.reporter.now = function(){return endTime}
|
||||||
|
self.reporter.reportRunnerResults(passingRun);
|
||||||
|
}
|
||||||
|
|
||||||
|
run(1000, 11000);
|
||||||
|
expect(this.fakeSys.getOutput()).toContain("10 seconds");
|
||||||
|
|
||||||
|
run(1000, 2000);
|
||||||
|
expect(this.fakeSys.getOutput()).toContain("1 seconds");
|
||||||
|
|
||||||
|
run(1000, 1100);
|
||||||
|
expect(this.fakeSys.getOutput()).toContain("0.1 seconds");
|
||||||
|
|
||||||
|
run(1000, 1010);
|
||||||
|
expect(this.fakeSys.getOutput()).toContain("0.01 seconds");
|
||||||
|
|
||||||
|
run(1000, 1001);
|
||||||
|
expect(this.fakeSys.getOutput()).toContain("0.001 seconds");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("altogether now", function(){
|
||||||
|
this.reporter.now = function(){return 1000}
|
||||||
|
this.reporter.reportRunnerStarting();
|
||||||
|
this.reporter.now = function(){return 1777}
|
||||||
|
this.reporter.reportRunnerResults(failingRun);
|
||||||
|
expect(this.fakeSys.getOutput()).toContain(red("Finished in 0.777 seconds"));
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,9 +22,9 @@ jasmine.TrivialNodeReporter = function(sys) {
|
||||||
function redF() { sys.print(redStr("F")); }
|
function redF() { sys.print(redStr("F")); }
|
||||||
function yellowStar() { sys.print(yellowStr("*")); }
|
function yellowStar() { sys.print(yellowStr("*")); }
|
||||||
|
|
||||||
function finished(colorF) { newline(); sys.print(colorF("Finished")); }
|
function finished(colorF, elapsed) { newline(); sys.print(colorF("Finished in " + elapsed/1000 + " seconds")); }
|
||||||
function greenFinished() { finished(greenStr); }
|
function greenFinished(elapsed) { finished(greenStr, elapsed); }
|
||||||
function redFinished() { finished(redStr); }
|
function redFinished(elapsed) { finished(redStr, elapsed); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +42,10 @@ jasmine.TrivialNodeReporter = function(sys) {
|
||||||
|
|
||||||
var startNewLineIfNecessary = lineEnder(defaultColumnsPerLine);
|
var startNewLineIfNecessary = lineEnder(defaultColumnsPerLine);
|
||||||
|
|
||||||
|
this.now = function() { return new Date().getTime(); }
|
||||||
|
|
||||||
this.reportRunnerStarting = function() {
|
this.reportRunnerStarting = function() {
|
||||||
|
this.runnerStartTime = this.now();
|
||||||
started();
|
started();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -59,10 +62,12 @@ jasmine.TrivialNodeReporter = function(sys) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.reportRunnerResults = function(runner) {
|
this.reportRunnerResults = function(runner) {
|
||||||
|
var elapsed = this.now() - this.runnerStartTime;
|
||||||
|
|
||||||
if (runner.results().failedCount === 0) {
|
if (runner.results().failedCount === 0) {
|
||||||
greenFinished();
|
greenFinished(elapsed);
|
||||||
} else {
|
} else {
|
||||||
redFinished();
|
redFinished(elapsed);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
Loading…
Reference in New Issue