* Removed old Queue & Runner in favor of Suite using the new QueueRunner
* New reporter interface across all reporters * xdescribe & xit now store disabled specs * Rewrite of HtmlReporter to support new interface and be more performant
This commit is contained in:
committed by
Dan Hansen and Davis W. Frank
parent
05977203a6
commit
3fc79bac9e
@@ -1,118 +1,4 @@
|
||||
//describe('Suite', function() {
|
||||
// var env;
|
||||
//
|
||||
// beforeEach(function() {
|
||||
// env = new jasmine.Env();
|
||||
// env.updateInterval = 0;
|
||||
// });
|
||||
//
|
||||
// describe('Specs', function () {
|
||||
// var suite;
|
||||
//
|
||||
// beforeEach(function() {
|
||||
// suite = env.describe('Suite 1', function () {
|
||||
// env.it('Spec 1', function() {
|
||||
// this.runs(function () {
|
||||
// this.expect(true).toEqual(true);
|
||||
// });
|
||||
// });
|
||||
// env.it('Spec 2', function() {
|
||||
// this.runs(function () {
|
||||
// this.expect(true).toEqual(true);
|
||||
// });
|
||||
// });
|
||||
// env.describe('Suite 2', function () {
|
||||
// env.it('Spec 3', function() {
|
||||
// this.runs(function () {
|
||||
// this.expect(true).toEqual(true);
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// env.it('Spec 4', function() {
|
||||
// this.runs(function () {
|
||||
// this.expect(true).toEqual(true);
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// it('#specs should return all immediate children that are specs.', function () {
|
||||
// var suiteSpecs = suite.specs();
|
||||
// expect(suiteSpecs.length).toEqual(3);
|
||||
// expect(suiteSpecs[0].description).toEqual('Spec 1');
|
||||
// expect(suiteSpecs[1].description).toEqual('Spec 2');
|
||||
// expect(suiteSpecs[2].description).toEqual('Spec 4');
|
||||
// });
|
||||
//
|
||||
// it("#suites should return all immediate children that are suites.", function() {
|
||||
// var nestedSuites = suite.suites();
|
||||
// expect(nestedSuites.length).toEqual(1);
|
||||
// expect(nestedSuites[0].description).toEqual('Suite 2');
|
||||
// });
|
||||
//
|
||||
// it("#children should return all immediate children including suites and specs.", function() {
|
||||
// var children = suite.children();
|
||||
// expect(children.length).toEqual(4);
|
||||
// expect(children[0].description).toEqual('Spec 1');
|
||||
// expect(children[1].description).toEqual('Spec 2');
|
||||
// expect(children[2].description).toEqual('Suite 2');
|
||||
// expect(children[3].description).toEqual('Spec 4');
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// describe('SpecCount', function () {
|
||||
//
|
||||
// it('should keep a count of the number of specs that are run', function() {
|
||||
// var suite = env.describe('one suite description', function () {
|
||||
// env.it('should be a test', function() {
|
||||
// this.runs(function () {
|
||||
// this.expect(true).toEqual(true);
|
||||
// });
|
||||
// });
|
||||
// env.it('should be another test', function() {
|
||||
// this.runs(function () {
|
||||
// this.expect(true).toEqual(true);
|
||||
// });
|
||||
// });
|
||||
// env.it('should be a third test', function() {
|
||||
// this.runs(function () {
|
||||
// this.expect(true).toEqual(true);
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// expect(suite.specs().length).toEqual(3);
|
||||
// });
|
||||
//
|
||||
// it('specCount should be correct even with runs/waits blocks', function() {
|
||||
// var suite = env.describe('one suite description', function () {
|
||||
// env.it('should be a test', function() {
|
||||
// this.runs(function () {
|
||||
// this.expect(true).toEqual(true);
|
||||
// });
|
||||
// });
|
||||
// env.it('should be another test', function() {
|
||||
// this.runs(function () {
|
||||
// this.expect(true).toEqual(true);
|
||||
// });
|
||||
// this.waits(10);
|
||||
// this.runs(function () {
|
||||
// this.expect(true).toEqual(true);
|
||||
// });
|
||||
// });
|
||||
// env.it('should be a third test', function() {
|
||||
// this.runs(function () {
|
||||
// this.expect(true).toEqual(true);
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// expect(suite.specs().length).toEqual(3);
|
||||
// });
|
||||
// });
|
||||
//});
|
||||
|
||||
describe("Suite (unit tests)", function() {
|
||||
describe("Suite", function() {
|
||||
|
||||
it("keeps its id", function() {
|
||||
var env = new jasmine.Env(),
|
||||
@@ -139,15 +25,16 @@ describe("Suite (unit tests)", function() {
|
||||
var env = new jasmine.Env(),
|
||||
parentSuite = new jasmine.Suite({
|
||||
env: env,
|
||||
description: "I am a suite"
|
||||
description: "I am a parent suite",
|
||||
parentSuite: jasmine.createSpy('pretend top level suite')
|
||||
}),
|
||||
suite = new jasmine.Suite({
|
||||
env: env,
|
||||
description: "I am a suite",
|
||||
parentSuite: parentSuite
|
||||
});
|
||||
suite = new jasmine.Suite({
|
||||
env: env,
|
||||
description: "I am a suite"
|
||||
});
|
||||
|
||||
expect(suite.getFullName()).toEqual("I am a suite");
|
||||
|
||||
expect(suite.getFullName()).toEqual("I am a parent suite I am a suite");
|
||||
});
|
||||
|
||||
it("adds before functions in order of needed execution", function() {
|
||||
@@ -182,9 +69,15 @@ describe("Suite (unit tests)", function() {
|
||||
|
||||
it("adds specs", function() {
|
||||
var env = new jasmine.Env(),
|
||||
fakeQueue = {
|
||||
add: jasmine.createSpy()
|
||||
},
|
||||
suite = new jasmine.Suite({
|
||||
env: env,
|
||||
description: "I am a suite"
|
||||
description: "I am a suite",
|
||||
queueFactory: function() {
|
||||
return fakeQueue
|
||||
}
|
||||
}),
|
||||
fakeSpec = {};
|
||||
|
||||
@@ -192,34 +85,146 @@ describe("Suite (unit tests)", function() {
|
||||
|
||||
suite.addSpec(fakeSpec);
|
||||
|
||||
expect(suite.specs.length).toEqual(1);git
|
||||
expect(suite.specs.length).toEqual(1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// TODO:
|
||||
describe("Suite (acceptance)", function() {
|
||||
|
||||
it("can execute and run all of its befores, specs, and afters", function() {
|
||||
it("adds suites", function() {
|
||||
var env = new jasmine.Env(),
|
||||
calls = [];
|
||||
|
||||
env.describe("A suite", function() {
|
||||
env.beforeEach(function() {
|
||||
calls.push('before');
|
||||
fakeQueue = {
|
||||
add: jasmine.createSpy()
|
||||
},
|
||||
suite = new jasmine.Suite({
|
||||
env: env,
|
||||
description: "I am a suite",
|
||||
queueFactory: function() {
|
||||
return fakeQueue
|
||||
}
|
||||
}),
|
||||
anotherSuite = new jasmine.Suite({
|
||||
env: env,
|
||||
description: "I am another suite",
|
||||
queueFactory: function() {
|
||||
return fakeQueue
|
||||
}
|
||||
});
|
||||
|
||||
env.it("with a spec", function() {
|
||||
calls.push('spec');
|
||||
});
|
||||
expect(suite.suites.length).toEqual(0);
|
||||
|
||||
env.afterEach(function() {
|
||||
calls.push('after');
|
||||
});
|
||||
});
|
||||
suite.addSuite(anotherSuite);
|
||||
|
||||
env.execute();
|
||||
expect(calls).toEqual(['before', 'spec', 'after']);
|
||||
expect(suite.suites.length).toEqual(1);
|
||||
});
|
||||
|
||||
});
|
||||
it("can be disabled", function() {
|
||||
var env = new jasmine.Env(),
|
||||
fakeQueueRunner = jasmine.createSpy('fake queue runner'),
|
||||
suite = new jasmine.Suite({
|
||||
env: env,
|
||||
description: "with a child suite",
|
||||
queueRunner: fakeQueueRunner
|
||||
});
|
||||
|
||||
suite.disable();
|
||||
|
||||
expect(suite.disabled).toBe(true);
|
||||
|
||||
suite.execute();
|
||||
|
||||
expect(fakeQueueRunner).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("delegates execution of its specs and suites", function() {
|
||||
var env = new jasmine.Env(),
|
||||
parentSuiteDone = jasmine.createSpy('parent suite done'),
|
||||
fakeQueueRunnerForParent = jasmine.createSpy('fake parent queue runner'),
|
||||
parentSuite = new jasmine.Suite({
|
||||
env: env,
|
||||
description: "I am a parent suite",
|
||||
queueRunner: fakeQueueRunnerForParent
|
||||
}),
|
||||
fakeQueueRunner = jasmine.createSpy('fake queue runner'),
|
||||
suite = new jasmine.Suite({
|
||||
env: env,
|
||||
description: "with a child suite",
|
||||
queueRunner: fakeQueueRunner
|
||||
}),
|
||||
fakeSpec1 = {
|
||||
execute: jasmine.createSpy('fakeSpec1')
|
||||
};
|
||||
|
||||
spyOn(suite, "execute");
|
||||
|
||||
parentSuite.addSpec(fakeSpec1);
|
||||
parentSuite.addSuite(suite);
|
||||
|
||||
parentSuite.execute(parentSuiteDone);
|
||||
|
||||
var parentSuiteFns = fakeQueueRunnerForParent.mostRecentCall.args[0].fns;
|
||||
|
||||
parentSuiteFns[0]();
|
||||
expect(fakeSpec1.execute).toHaveBeenCalled();
|
||||
parentSuiteFns[1]();
|
||||
expect(suite.execute).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("calls a provided onStart callback when starting", function() {
|
||||
var env = new jasmine.Env(),
|
||||
suiteStarted = jasmine.createSpy('suiteStarted'),
|
||||
fakeQueueRunner = function(attrs) { attrs.onComplete(); },
|
||||
suite = new jasmine.Suite({
|
||||
env: env,
|
||||
description: "with a child suite",
|
||||
onStart: suiteStarted,
|
||||
queueRunner: fakeQueueRunner
|
||||
}),
|
||||
fakeSpec1 = {
|
||||
execute: jasmine.createSpy('fakeSpec1')
|
||||
};
|
||||
|
||||
suite.execute();
|
||||
|
||||
expect(suiteStarted).toHaveBeenCalledWith(suite);
|
||||
});
|
||||
|
||||
it("calls a provided onComplete callback when done", function() {
|
||||
var env = new jasmine.Env(),
|
||||
suiteCompleted = jasmine.createSpy('parent suite done'),
|
||||
fakeQueueRunner = function(attrs) { attrs.onComplete(); },
|
||||
suite = new jasmine.Suite({
|
||||
env: env,
|
||||
description: "with a child suite",
|
||||
queueRunner: fakeQueueRunner
|
||||
}),
|
||||
fakeSpec1 = {
|
||||
execute: jasmine.createSpy('fakeSpec1')
|
||||
};
|
||||
|
||||
suite.execute(suiteCompleted);
|
||||
|
||||
expect(suiteCompleted).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("calls a provided result callback when done", function() {
|
||||
var env = new jasmine.Env(),
|
||||
suiteResultsCallback = jasmine.createSpy('suite result callback'),
|
||||
fakeQueueRunner = function(attrs) { attrs.onComplete(); },
|
||||
suite = new jasmine.Suite({
|
||||
env: env,
|
||||
description: "with a child suite",
|
||||
queueRunner: fakeQueueRunner,
|
||||
resultCallback: suiteResultsCallback
|
||||
}),
|
||||
fakeSpec1 = {
|
||||
execute: jasmine.createSpy('fakeSpec1')
|
||||
};
|
||||
|
||||
suite.execute();
|
||||
|
||||
expect(suiteResultsCallback).toHaveBeenCalledWith({
|
||||
id: suite.id,
|
||||
status: '',
|
||||
description: "with a child suite",
|
||||
fullName: "with a child suite"
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user