print elapsed time in summary

This commit is contained in:
Steve Conover
2011-02-28 15:31:48 -08:00
parent e8c8a0bdfd
commit eb49fab652
2 changed files with 54 additions and 6 deletions

View File

@@ -34,7 +34,8 @@ describe("TrivialNodeReporter", function() {
return {
puts:function(str) {output += str + "\n";},
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")
);
});
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"));
});
});
});