Remove results from Queue

- consequently, Runner & Suite no longer have results.
- Results come back to reporters from Spec, we should not have a need to
  walk them later via suite/runner (in fact, no reporter used results on
  suite/runner -- only bad tests)
- Remove/clean up tests relying on #results
- Remove integration tests that duplicate already tested behavior
This commit is contained in:
Davis W. Frank & Rajan Agaskar
2012-11-30 10:08:20 -08:00
parent 1f5e790c41
commit 779dee1211
18 changed files with 354 additions and 1682 deletions

View File

@@ -14,105 +14,83 @@ describe('RunnerTest', function() {
});
describe('beforeEach', function() {
it('should run before each spec for all suites', function () {
it('should run before each spec for all suites', function() {
var foo;
env.beforeEach(function () {
env.beforeEach(function() {
foo = 0;
});
env.describe('suite 1', function () {
env.describe('suite 1', function() {
env.it('test 1-1', function() {
foo++;
this.expect(foo).toEqual(1);
expect(foo).toEqual(1);
});
env.it('test 1-2', function() {
foo++;
this.expect(foo).toEqual(1);
expect(foo).toEqual(1);
});
});
env.describe('suite 2', function () {
env.describe('suite 2', function() {
env.it('test 2-1', function() {
foo++;
this.expect(foo).toEqual(1);
expect(foo).toEqual(1);
});
});
env.currentRunner().execute();
var runnerResults = env.currentRunner().results();
expect(runnerResults.totalCount).toEqual(3);
expect(runnerResults.passedCount).toEqual(3);
});
it('should provide all specs', function() {
it('should provide all specs', function () {
var foo;
env.beforeEach(function () {
foo = 0;
});
env.describe('suite 1', function () {
env.describe('suite 1', function() {
env.it('test 1-1', function() {
foo++;
this.expect(foo).toEqual(1);
});
env.it('test 1-2', function() {
foo++;
this.expect(foo).toEqual(1);
});
});
env.describe('suite 2', function () {
env.describe('suite 2', function() {
env.it('test 2-1', function() {
foo++;
this.expect(foo).toEqual(1);
});
});
env.currentRunner().execute();
expect(env.currentRunner().specs().length).toEqual(3);
});
});
describe('afterEach', function() {
it('should run after each spec for all suites', function () {
it('should run after each spec for all suites', function() {
var foo = 3;
env.afterEach(function () {
env.afterEach(function() {
foo = foo - 1;
});
env.describe('suite 1', function () {
env.describe('suite 1', function() {
env.it('test 1-1', function() {
this.expect(foo).toEqual(3);
expect(foo).toEqual(3);
});
env.it('test 1-2', function() {
this.expect(foo).toEqual(2);
expect(foo).toEqual(2);
});
});
env.describe('suite 2', function () {
env.describe('suite 2', function() {
env.it('test 2-1', function() {
this.expect(foo).toEqual(1);
expect(foo).toEqual(1);
});
});
env.currentRunner().execute();
var runnerResults = env.currentRunner().results();
expect(runnerResults.totalCount).toEqual(3);
expect(runnerResults.passedCount).toEqual(3);
});
it('should run after a failing spec', function () {
var afterEach = originalJasmine.createSpy();
env.afterEach(afterEach);
env.describe('suite', function () {
env.it('fails', function () {
this.explodes();
env.describe('suite',function() {
env.it('fails', function() {
this.fail();
});
}).execute();
@@ -120,103 +98,32 @@ describe('RunnerTest', function() {
});
});
it('should run child suites and specs and generate results when execute is called', function() {
env.describe('one suite description', function () {
env.it('should be a test', function() {
this.runs(function () {
this.expect(true).toEqual(true);
});
});
});
env.describe('another suite description', function () {
env.it('should be another test', function() {
this.runs(function () {
this.expect(true).toEqual(false);
});
});
});
env.currentRunner().execute();
var runnerResults = env.currentRunner().results();
expect(runnerResults.totalCount).toEqual(2);
expect(runnerResults.passedCount).toEqual(1);
expect(runnerResults.failedCount).toEqual(1);
});
it('should ignore suites that have been x\'d', function() {
env.xdescribe('one suite description', function () {
env.it('should be a test', function() {
this.runs(function () {
this.expect(true).toEqual(true);
});
});
});
env.describe('another suite description', function () {
env.it('should be another test', function() {
this.runs(function () {
this.expect(true).toEqual(false);
});
});
});
var disabledDescribe = jasmine.createSpy('xdescribe');
env.xdescribe('one suite description', disabledDescribe);
env.currentRunner().execute();
var runnerResults = env.currentRunner().results();
expect(runnerResults.totalCount).toEqual(1);
expect(runnerResults.passedCount).toEqual(0);
expect(runnerResults.failedCount).toEqual(1);
expect(disabledDescribe).not.toHaveBeenCalled();
});
it('should roll up results from all specs', function() {
env.describe('one suite description', function () {
env.it('should be a test', function() {
this.runs(function () {
this.expect(true).toEqual(true);
});
});
});
env.describe('another suite description', function () {
env.it('should be another test', function() {
this.runs(function () {
this.expect(true).toEqual(false);
});
});
});
env.currentRunner().execute();
var results = env.currentRunner().results();
expect(results.totalCount).toEqual(2);
expect(results.passedCount).toEqual(1);
expect(results.failedCount).toEqual(1);
});
describe('reporting', function () {
describe('reporting', function() {
var fakeReporter;
beforeEach(function () {
fakeReporter = originalJasmine.createSpyObj("fakeReporter", ["log", "reportRunnerStarting", "reportRunnerResults"]);
env.addReporter(fakeReporter);
});
it('should report runner results when the runner has completed running', function() {
env.describe('one suite description', function () {
env.describe('one suite description', function() {
env.it('should be a test', function() {
this.runs(function () {
this.runs(function() {
this.expect(true).toEqual(true);
});
});
});
env.describe('another suite description', function () {
env.describe('another suite description', function() {
env.it('should be another test', function() {
this.waits(200);
this.runs(function () {
this.runs(function() {
this.expect(true).toEqual(false);
});
});
@@ -225,10 +132,7 @@ describe('RunnerTest', function() {
env.currentRunner().execute();
expect(fakeReporter.reportRunnerResults).not.toHaveBeenCalled();
fakeTimer.tick(200);
//This blows up the JSApiReporter.
//expect(fakeReporter.reportRunnerResults).toHaveBeenCalledWith(env.currentRunner);
expect(fakeReporter.reportRunnerResults).toHaveBeenCalled();
expect(fakeReporter.reportRunnerResults.mostRecentCall.args[0].results()).toEqual(env.currentRunner().results());
expect(fakeReporter.reportRunnerResults).toHaveBeenCalledWith(env.currentRunner());
});
});
@@ -264,7 +168,8 @@ describe('RunnerTest', function() {
suite2 = env.describe("suite 2", function() {
});
});
suite3 = env.describe("suite 3", function() {});
suite3 = env.describe("suite 3", function() {
});
});
it("#suites should return a flat array of all suites, including nested suites", function() {