Add reportRunnerStarting callback to reporters.
This commit is contained in:
parent
e1408a9f58
commit
f451e633cb
@ -852,6 +852,10 @@ jasmine.ActionCollection.prototype.waitForDone = function(action) {
|
||||
jasmine.Reporter = function() {
|
||||
};
|
||||
|
||||
//noinspection JSUnusedLocalSymbols
|
||||
jasmine.Reporter.prototype.reportRunnerStarting = function(runner) {
|
||||
};
|
||||
|
||||
//noinspection JSUnusedLocalSymbols
|
||||
jasmine.Reporter.prototype.reportRunnerResults = function(runner) {
|
||||
};
|
||||
@ -1311,13 +1315,16 @@ jasmine.MultiReporter.prototype.addReporter = function(reporter) {
|
||||
};
|
||||
|
||||
(function() {
|
||||
var functionNames = ["reportRunnerResults", "reportSuiteResults", "reportSpecResults", "log"];
|
||||
var functionNames = ["reportRunnerStarting", "reportRunnerResults", "reportSuiteResults", "reportSpecResults", "log"];
|
||||
for (var i = 0; i < functionNames.length; i++) {
|
||||
var functionName = functionNames[i];
|
||||
jasmine.MultiReporter.prototype[functionName] = (function(functionName) {
|
||||
return function() {
|
||||
for (var j = 0; j < this.subReporters_.length; j++) {
|
||||
this.subReporters_[j][functionName].apply(this.subReporters_[j], arguments);
|
||||
var subReporter = this.subReporters_[j];
|
||||
if (subReporter[functionName]) {
|
||||
subReporter[functionName].apply(subReporter, arguments);
|
||||
}
|
||||
}
|
||||
};
|
||||
})(functionName);
|
||||
@ -1648,6 +1655,13 @@ jasmine.Runner = function(env) {
|
||||
};
|
||||
jasmine.util.inherit(jasmine.Runner, jasmine.ActionCollection);
|
||||
|
||||
jasmine.Runner.prototype.execute = function() {
|
||||
if (this.env.reporter.reportRunnerStarting) {
|
||||
this.env.reporter.reportRunnerStarting(this);
|
||||
}
|
||||
jasmine.ActionCollection.prototype.execute.call(this);
|
||||
};
|
||||
|
||||
jasmine.Runner.prototype.finishCallback = function() {
|
||||
this.env.reporter.reportRunnerResults(this);
|
||||
};
|
||||
|
@ -13,9 +13,5 @@ describe("jasmine.Env", function() {
|
||||
env.reporter.log("message");
|
||||
expect(fakeReporter.log).wasCalledWith("message");
|
||||
});
|
||||
|
||||
xit("should report when the tests start running", function() {
|
||||
|
||||
});
|
||||
});
|
||||
});
|
@ -1,13 +1,30 @@
|
||||
describe("jasmine.MultiReporter", function() {
|
||||
it("should delegate to any and all subreporters", function() {
|
||||
var multiReporter = new jasmine.MultiReporter();
|
||||
var fakeReporter1 = jasmine.createSpyObj("fakeReporter1", ["reportSpecResults"]);
|
||||
var fakeReporter2 = jasmine.createSpyObj("fakeReporter2", ["reportSpecResults"]);
|
||||
var multiReporter, fakeReporter1, fakeReporter2;
|
||||
|
||||
beforeEach(function() {
|
||||
multiReporter = new jasmine.MultiReporter();
|
||||
fakeReporter1 = jasmine.createSpyObj("fakeReporter1", ["reportSpecResults"]);
|
||||
fakeReporter2 = jasmine.createSpyObj("fakeReporter2", ["reportSpecResults", "reportRunnerStarting"]);
|
||||
multiReporter.addReporter(fakeReporter1);
|
||||
multiReporter.addReporter(fakeReporter2);
|
||||
});
|
||||
|
||||
it("should support all the method calls that jasmine.Reporter supports", function() {
|
||||
multiReporter.reportRunnerStarting();
|
||||
multiReporter.reportRunnerResults();
|
||||
multiReporter.reportSuiteResults();
|
||||
multiReporter.reportSpecResults();
|
||||
multiReporter.log();
|
||||
});
|
||||
|
||||
it("should delegate to any and all subreporters", function() {
|
||||
multiReporter.reportSpecResults('blah', 'foo');
|
||||
expect(fakeReporter1.reportSpecResults).wasCalledWith('blah', 'foo');
|
||||
expect(fakeReporter2.reportSpecResults).wasCalledWith('blah', 'foo');
|
||||
});
|
||||
|
||||
it("should quietly skip delegating to any subreporters which lack the given method", function() {
|
||||
multiReporter.reportRunnerStarting('blah', 'foo');
|
||||
expect(fakeReporter2.reportRunnerStarting).wasCalledWith('blah', 'foo');
|
||||
});
|
||||
});
|
@ -114,4 +114,13 @@ describe('RunnerTest', function() {
|
||||
expect(foo).toEqual(1);
|
||||
});
|
||||
|
||||
it("should report when the tests start running", function() {
|
||||
var fakeReporter = jasmine.createSpyObj("fakeReporter", ["log", "reportRunnerStarting"]);
|
||||
env.addReporter(fakeReporter);
|
||||
|
||||
var runner = new jasmine.Runner(env);
|
||||
runner.execute();
|
||||
expect(fakeReporter.reportRunnerStarting).wasCalledWith(env.currentRunner);
|
||||
});
|
||||
|
||||
});
|
@ -11,13 +11,16 @@ jasmine.MultiReporter.prototype.addReporter = function(reporter) {
|
||||
};
|
||||
|
||||
(function() {
|
||||
var functionNames = ["reportRunnerResults", "reportSuiteResults", "reportSpecResults", "log"];
|
||||
var functionNames = ["reportRunnerStarting", "reportRunnerResults", "reportSuiteResults", "reportSpecResults", "log"];
|
||||
for (var i = 0; i < functionNames.length; i++) {
|
||||
var functionName = functionNames[i];
|
||||
jasmine.MultiReporter.prototype[functionName] = (function(functionName) {
|
||||
return function() {
|
||||
for (var j = 0; j < this.subReporters_.length; j++) {
|
||||
this.subReporters_[j][functionName].apply(this.subReporters_[j], arguments);
|
||||
var subReporter = this.subReporters_[j];
|
||||
if (subReporter[functionName]) {
|
||||
subReporter[functionName].apply(subReporter, arguments);
|
||||
}
|
||||
}
|
||||
};
|
||||
})(functionName);
|
||||
|
@ -5,6 +5,10 @@
|
||||
jasmine.Reporter = function() {
|
||||
};
|
||||
|
||||
//noinspection JSUnusedLocalSymbols
|
||||
jasmine.Reporter.prototype.reportRunnerStarting = function(runner) {
|
||||
};
|
||||
|
||||
//noinspection JSUnusedLocalSymbols
|
||||
jasmine.Reporter.prototype.reportRunnerResults = function(runner) {
|
||||
};
|
||||
|
@ -11,6 +11,13 @@ jasmine.Runner = function(env) {
|
||||
};
|
||||
jasmine.util.inherit(jasmine.Runner, jasmine.ActionCollection);
|
||||
|
||||
jasmine.Runner.prototype.execute = function() {
|
||||
if (this.env.reporter.reportRunnerStarting) {
|
||||
this.env.reporter.reportRunnerStarting(this);
|
||||
}
|
||||
jasmine.ActionCollection.prototype.execute.call(this);
|
||||
};
|
||||
|
||||
jasmine.Runner.prototype.finishCallback = function() {
|
||||
this.env.reporter.reportRunnerResults(this);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user