spec failure - description

This commit is contained in:
Steve Conover 2011-02-28 17:13:04 -08:00
parent 9704550b33
commit 5018f0d1c2
2 changed files with 44 additions and 1 deletions

View File

@ -153,6 +153,29 @@ describe("TrivialNodeReporter", function() {
});
describe('Finishes', function(){
describe('Spec failure information', function(){
it("prints suite and spec descriptions together as a sentence", function(){
this.reporter.suiteResults = [
{description:"The oven", failedSpecResults:[
{description:"heats up"},
{description:"cleans itself"}
]},
{description:"The mixer", failedSpecResults:[
{description:"blends things together"}
]}
]
this.reporter.reportRunnerResults(failingRun);
expect(this.fakeSys.getOutput()).toContain("The oven heats up");
expect(this.fakeSys.getOutput()).toContain("The oven cleans itself");
expect(this.fakeSys.getOutput()).toContain("The mixer blends things together");
});
})
describe('Finished line', function(){
it("prints the elapsed time in the summary message", function(){

View File

@ -30,11 +30,17 @@ jasmine.TrivialNodeReporter = function(sys) {
function plural(str, count) { return count == 1 ? str : str + "s"; }
function specFailureDetails(suiteDescription, specDescription) {
newline();
sys.print(suiteDescription + " " + specDescription);
newline();
}
function finished(elapsed) { newline(); sys.print("Finished in " + elapsed/1000 + " seconds"); }
function summary(colorF, specs, assertions, failed) { newline();
colorF(sys.print(specs + " " + plural(language.spec, specs) + ", " +
assertions + " " + plural(language.assertion, assertions) + ", " +
failed + " " + plural(language.failure, failed))); }
failed + " " + plural(language.failure, failed)));
newline(); }
function greenSummary(specs, assertions, failed){ summary(greenStr, specs, assertions, failed); }
function redSummary(specs, assertions, failed){ summary(redStr, specs, assertions, failed); }
@ -94,7 +100,21 @@ jasmine.TrivialNodeReporter = function(sys) {
this.suiteResults.push(suiteResult);
};
function eachSpecFailure(suiteResults, callback) {
for(var i=0; i<suiteResults.length; i++) {
var suiteResult = suiteResults[i];
for(var j=0; j<suiteResult.failedSpecResults.length; j++) {
var failedSpecResult = suiteResult.failedSpecResults[j];
callback(suiteResult.description, failedSpecResult.description);
}
}
}
this.reportRunnerResults = function(runner) {
eachSpecFailure(this.suiteResults, function(suiteDescription, specDescription) {
specFailureDetails(suiteDescription, specDescription);
})
finished(this.now() - this.runnerStartTime);
var results = runner.results();