Skip to content

Commit

Permalink
Added elapsed time information in test suite run.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Nelson & Brian Takita authored and Jan Nelson & Brian Takita committed Sep 2, 2008
1 parent e3c2500 commit 4d34899
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/screw.behaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
$(Screw).bind('loaded', function() {
$('.status').fn({
display: function() {
$(this).text(
$('.passed').length + $('.failed').length + ' test(s), ' + $('.failed').length + ' failure(s)'
$(this).html(
$('.passed').length + $('.failed').length + ' test(s), ' + $('.failed').length + ' failure(s)<br />' +
((new Date() - Screw.suite_start_time)/1000.0).toString() + " seconds elapsed"
);
}
});
Expand Down
1 change: 1 addition & 0 deletions lib/screw.events.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
})
})
.bind('before', function() {
Screw.suite_start_time = new Date();
$('.status').text('Running...');
})
.bind('after', function() {
Expand Down
12 changes: 11 additions & 1 deletion spec/behaviors_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@ Screw.Unit(function() {
var global_before_invoked = false, global_after_invoked = false;
before(function() { global_before_invoked = true });
after(function() { global_after_invoked = true });

describe('Behaviors', function() {
describe('#run', function() {
describe("elapsed time", function() {
it("displays the elapsed time after the Suite finishes", function() {
var status = $(".status");
status.fn("display");
var time_elapsed_matches = /([0-9]+\.[0-9]+) seconds/.exec(status.html());
var time_elapsed = parseFloat(time_elapsed_matches[1]);
expect(time_elapsed > 0.0).to(be_true);
});
});

describe("a simple [describe]", function() {
it("invokes the global [before] before an [it]", function() {
expect(global_before_invoked).to(equal, true);
Expand Down

0 comments on commit 4d34899

Please sign in to comment.