integration test - failure scenario
This commit is contained in:
parent
e42026ee84
commit
b9cbd3c5a0
@ -51,7 +51,7 @@ describe("TrivialConsoleReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('Integration test', function(){
|
describe('Integration', function(){
|
||||||
it("prints the proper output under a pass scenario. small numbers.", function(){
|
it("prints the proper output under a pass scenario. small numbers.", function(){
|
||||||
simulateRun(this.reporter,
|
simulateRun(this.reporter,
|
||||||
repeat(passingSpec, 3),
|
repeat(passingSpec, 3),
|
||||||
@ -121,6 +121,70 @@ describe("TrivialConsoleReporter", function() {
|
|||||||
].join("\n") + "\n"
|
].join("\n") + "\n"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it("prints the proper output under a failure scenario.", function(){
|
||||||
|
simulateRun(this.reporter,
|
||||||
|
[failingSpec, passingSpec, failingSpec],
|
||||||
|
[{description:"The oven",
|
||||||
|
results:function(){
|
||||||
|
return {
|
||||||
|
items_:[
|
||||||
|
{failedCount:2,
|
||||||
|
description:"heats up",
|
||||||
|
items_:[
|
||||||
|
{trace:{stack:"stack trace one\n second line"}},
|
||||||
|
{trace:{stack:"stack trace two"}}
|
||||||
|
]}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}},
|
||||||
|
{description:"The washing machine",
|
||||||
|
results:function(){
|
||||||
|
return {
|
||||||
|
items_:[
|
||||||
|
{failedCount:2,
|
||||||
|
description:"washes clothes",
|
||||||
|
items_:[
|
||||||
|
{trace:{stack:"stack trace one"}}
|
||||||
|
]}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
],
|
||||||
|
{
|
||||||
|
results:function(){
|
||||||
|
return {
|
||||||
|
specs: function(){return [null, null, null];},
|
||||||
|
totalCount: 7,
|
||||||
|
failedCount: 2
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
1000,
|
||||||
|
1777);
|
||||||
|
|
||||||
|
expect(this.out.getOutput()).toEqual(
|
||||||
|
[
|
||||||
|
"Started",
|
||||||
|
red("F") + green(".") + red("F"),
|
||||||
|
"",
|
||||||
|
"The oven heats up",
|
||||||
|
" stack trace one",
|
||||||
|
" second line",
|
||||||
|
" stack trace two",
|
||||||
|
"",
|
||||||
|
"The washing machine washes clothes",
|
||||||
|
" stack trace one",
|
||||||
|
"",
|
||||||
|
"Finished in 0.777 seconds",
|
||||||
|
red("3 specs, 7 assertions, 2 failures"),
|
||||||
|
""
|
||||||
|
].join("\n") + "\n"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('A Test Run', function(){
|
describe('A Test Run', function(){
|
||||||
|
@ -30,17 +30,30 @@ jasmine.TrivialConsoleReporter = function(print) {
|
|||||||
|
|
||||||
function plural(str, count) { return count == 1 ? str : str + "s"; }
|
function plural(str, count) { return count == 1 ? str : str + "s"; }
|
||||||
|
|
||||||
|
function repeat(thing, times) { var arr = [];
|
||||||
|
for(var i=0; i<times; i++) arr.push(thing);
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function indent(str, spaces) { var lines = str.split("\n");
|
||||||
|
var newArr = []
|
||||||
|
for(var i=0; i<lines.length; i++) {
|
||||||
|
newArr.push(repeat(" ", spaces).join("") + lines[i])
|
||||||
|
}
|
||||||
|
return newArr.join("\n")
|
||||||
|
}
|
||||||
|
|
||||||
function specFailureDetails(suiteDescription, specDescription, stackTraces) {
|
function specFailureDetails(suiteDescription, specDescription, stackTraces) {
|
||||||
newline();
|
newline();
|
||||||
print(suiteDescription + " " + specDescription);
|
print(suiteDescription + " " + specDescription);
|
||||||
newline();
|
newline();
|
||||||
for(var i=0; i<stackTraces.length; i++) {
|
for(var i=0; i<stackTraces.length; i++) {
|
||||||
print(stackTraces[i]);
|
print(indent(stackTraces[i], 2));
|
||||||
newline();
|
newline();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function finished(elapsed) { newline();
|
function finished(elapsed) { newline();
|
||||||
newline();
|
|
||||||
print("Finished in " + elapsed/1000 + " seconds"); }
|
print("Finished in " + elapsed/1000 + " seconds"); }
|
||||||
function summary(colorF, specs, assertions, failed) { newline();
|
function summary(colorF, specs, assertions, failed) { newline();
|
||||||
print(colorF(specs + " " + plural(language.spec, specs) + ", " +
|
print(colorF(specs + " " + plural(language.spec, specs) + ", " +
|
||||||
@ -120,6 +133,8 @@ jasmine.TrivialConsoleReporter = function(print) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.reportRunnerResults = function(runner) {
|
this.reportRunnerResults = function(runner) {
|
||||||
|
newline();
|
||||||
|
|
||||||
eachSpecFailure(this.suiteResults, function(suiteDescription, specDescription, stackTraces) {
|
eachSpecFailure(this.suiteResults, function(suiteDescription, specDescription, stackTraces) {
|
||||||
specFailureDetails(suiteDescription, specDescription, stackTraces);
|
specFailureDetails(suiteDescription, specDescription, stackTraces);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user