added failure count to top of trivial reporter

This commit is contained in:
Erik Hanson 2009-08-12 10:15:15 -07:00
parent 93c7b092b3
commit 4410c7cd94
3 changed files with 24 additions and 2 deletions

View File

@ -29,6 +29,10 @@ jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarA
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
var suites = runner.getAllSuites();
this.runnerDiv = this.createDom('div', { className: 'runner running' }, "Running...");
this.document.body.appendChild(this.runnerDiv);
for (var i = 0; i < suites.length; i++) {
var suite = suites[i];
var suiteDiv = this.createDom('div', { className: 'suite' },
@ -46,6 +50,14 @@ jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
};
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
this.log(">>>>>>>>>>>>>>>>>");
this.log(runner.getResults());
var results = runner.getResults();
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
this.runnerDiv.setAttribute("class", className);
var message = results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
this.runnerDiv.replaceChild(this.document.createTextNode(message), this.runnerDiv.firstChild);
};
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {

View File

@ -23,6 +23,16 @@ p {
color: red;
}
.runner {
border: 1px outset gray;
margin: 5px;
padding-left: 1em;
}
.runner.running {
background-color: yellow;
}
.suite {
border: 1px outset gray;
margin: 5px;

View File

@ -28,7 +28,7 @@ describe("TrivialReporter", function() {
});
var divs = body.getElementsByTagName("div");
expect(divs.length).toEqual(1);
expect(divs[0].innerHTML).toContain("suite 1");
expect(divs.length).toEqual(2);
expect(divs[1].innerHTML).toContain("suite 1");
});
});