stack traces

This commit is contained in:
Steve Conover 2011-02-28 17:20:22 -08:00
parent 5018f0d1c2
commit b1dceeacd4
2 changed files with 34 additions and 10 deletions

View File

@ -159,13 +159,13 @@ describe("TrivialNodeReporter", function() {
it("prints suite and spec descriptions together as a sentence", function(){ it("prints suite and spec descriptions together as a sentence", function(){
this.reporter.suiteResults = [ this.reporter.suiteResults = [
{description:"The oven", failedSpecResults:[ {description:"The oven", failedSpecResults:[
{description:"heats up"}, {description:"heats up", items_:[]},
{description:"cleans itself"} {description:"cleans itself", items_:[]}
]}, ]},
{description:"The mixer", failedSpecResults:[ {description:"The mixer", failedSpecResults:[
{description:"blends things together"} {description:"blends things together", items_:[]}
]} ]}
] ];
this.reporter.reportRunnerResults(failingRun); this.reporter.reportRunnerResults(failingRun);
@ -174,7 +174,25 @@ describe("TrivialNodeReporter", function() {
expect(this.fakeSys.getOutput()).toContain("The mixer blends things together"); expect(this.fakeSys.getOutput()).toContain("The mixer blends things together");
}); });
}) it("prints stack trace of spec failure", function(){
this.reporter.suiteResults = [
{description:"The oven", failedSpecResults:[
{description:"heats up",
items_:[
{trace:{stack:"stack trace one"}},
{trace:{stack:"stack trace two"}}
]}
]}
];
this.reporter.reportRunnerResults(failingRun);
expect(this.fakeSys.getOutput()).toContain("The oven heats up");
expect(this.fakeSys.getOutput()).toContain("stack trace one");
expect(this.fakeSys.getOutput()).toContain("stack trace two");
});
});
describe('Finished line', function(){ describe('Finished line', function(){

View File

@ -30,10 +30,14 @@ jasmine.TrivialNodeReporter = function(sys) {
function plural(str, count) { return count == 1 ? str : str + "s"; } function plural(str, count) { return count == 1 ? str : str + "s"; }
function specFailureDetails(suiteDescription, specDescription) { function specFailureDetails(suiteDescription, specDescription, stackTraces) {
newline(); newline();
sys.print(suiteDescription + " " + specDescription); sys.print(suiteDescription + " " + specDescription);
newline(); newline();
for(var i=0; i<stackTraces.length; i++) {
sys.print(stackTraces[i]);
newline();
}
} }
function finished(elapsed) { newline(); sys.print("Finished in " + elapsed/1000 + " seconds"); } function finished(elapsed) { newline(); sys.print("Finished in " + elapsed/1000 + " seconds"); }
function summary(colorF, specs, assertions, failed) { newline(); function summary(colorF, specs, assertions, failed) { newline();
@ -105,15 +109,17 @@ jasmine.TrivialNodeReporter = function(sys) {
var suiteResult = suiteResults[i]; var suiteResult = suiteResults[i];
for(var j=0; j<suiteResult.failedSpecResults.length; j++) { for(var j=0; j<suiteResult.failedSpecResults.length; j++) {
var failedSpecResult = suiteResult.failedSpecResults[j]; var failedSpecResult = suiteResult.failedSpecResults[j];
callback(suiteResult.description, failedSpecResult.description); var stackTraces = [];
for(var k=0; k<failedSpecResult.items_.length; k++) stackTraces.push(failedSpecResult.items_[k].trace.stack);
callback(suiteResult.description, failedSpecResult.description, stackTraces);
} }
} }
} }
this.reportRunnerResults = function(runner) { this.reportRunnerResults = function(runner) {
eachSpecFailure(this.suiteResults, function(suiteDescription, specDescription) { eachSpecFailure(this.suiteResults, function(suiteDescription, specDescription, stackTraces) {
specFailureDetails(suiteDescription, specDescription); specFailureDetails(suiteDescription, specDescription, stackTraces);
}) });
finished(this.now() - this.runnerStartTime); finished(this.now() - this.runnerStartTime);