2009-05-29 03:02:15 +00:00
|
|
|
describe('RunnerTest', function() {
|
2009-08-13 05:12:28 +00:00
|
|
|
var fakeTimer;
|
2009-05-29 03:02:15 +00:00
|
|
|
var env;
|
2009-08-13 05:12:28 +00:00
|
|
|
|
|
|
|
beforeEach(function() {
|
2009-05-29 03:02:15 +00:00
|
|
|
env = new jasmine.Env();
|
|
|
|
|
2009-08-13 05:12:28 +00:00
|
|
|
fakeTimer = new jasmine.FakeTimer();
|
|
|
|
env.setTimeout = fakeTimer.setTimeout;
|
|
|
|
env.clearTimeout = fakeTimer.clearTimeout;
|
|
|
|
env.setInterval = fakeTimer.setInterval;
|
|
|
|
env.clearInterval = fakeTimer.clearInterval;
|
2009-05-29 03:02:15 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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();
|
2009-08-13 14:52:44 +00:00
|
|
|
fakeTimer.tick(0);
|
2009-05-29 03:02:15 +00:00
|
|
|
|
2009-08-08 15:53:15 +00:00
|
|
|
var runnerResults = env.currentRunner.getResults();
|
|
|
|
expect(runnerResults.totalCount).toEqual(2);
|
|
|
|
expect(runnerResults.passedCount).toEqual(1);
|
|
|
|
expect(runnerResults.failedCount).toEqual(1);
|
2009-05-29 03:02:15 +00:00
|
|
|
});
|
|
|
|
|
2009-08-08 15:53:15 +00:00
|
|
|
|
2009-05-29 03:02:15 +00:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
env.currentRunner.execute();
|
2009-08-13 14:52:44 +00:00
|
|
|
fakeTimer.tick(0);
|
|
|
|
|
2009-08-13 05:12:28 +00:00
|
|
|
var runnerResults = env.currentRunner.getResults();
|
|
|
|
expect(runnerResults.totalCount).toEqual(1);
|
|
|
|
expect(runnerResults.passedCount).toEqual(0);
|
|
|
|
expect(runnerResults.failedCount).toEqual(1);
|
2009-05-29 03:02:15 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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();
|
2009-08-13 14:52:44 +00:00
|
|
|
fakeTimer.tick(0);
|
|
|
|
|
2009-05-29 03:02:15 +00:00
|
|
|
var results = env.currentRunner.getResults();
|
|
|
|
expect(results.totalCount).toEqual(2);
|
|
|
|
expect(results.passedCount).toEqual(1);
|
|
|
|
expect(results.failedCount).toEqual(1);
|
|
|
|
});
|
|
|
|
|
2009-08-13 05:12:28 +00:00
|
|
|
describe('reporting', function () {
|
|
|
|
var fakeReporter;
|
|
|
|
beforeEach(function () {
|
|
|
|
fakeReporter = jasmine.createSpyObj("fakeReporter", ["log", "reportRunnerStarting", "reportRunnerResults"]);
|
|
|
|
env.addReporter(fakeReporter);
|
|
|
|
});
|
2009-06-15 15:14:55 +00:00
|
|
|
|
2009-08-13 05:12:28 +00:00
|
|
|
it('should report runner results when the runner has completed running', function() {
|
|
|
|
env.describe('one suite description', function () {
|
|
|
|
env.it('should be a test', function() {
|
|
|
|
this.runs(function () {
|
|
|
|
this.expect(true).toEqual(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2009-06-15 15:14:55 +00:00
|
|
|
|
2009-08-13 05:12:28 +00:00
|
|
|
env.describe('another suite description', function () {
|
|
|
|
env.it('should be another test', function() {
|
|
|
|
this.waits(200);
|
|
|
|
this.runs(function () {
|
|
|
|
this.expect(true).toEqual(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2009-06-15 15:14:55 +00:00
|
|
|
|
2009-08-13 05:12:28 +00:00
|
|
|
env.currentRunner.execute();
|
|
|
|
expect(fakeReporter.reportRunnerResults).wasNotCalled();
|
|
|
|
fakeTimer.tick(200);
|
|
|
|
expect(fakeReporter.reportRunnerResults).wasCalledWith(env.currentRunner);
|
|
|
|
});
|
2009-06-15 15:14:55 +00:00
|
|
|
|
2009-08-13 05:12:28 +00:00
|
|
|
it("should report when the tests start running", function() {
|
|
|
|
expect(fakeReporter.reportRunnerStarting).wasNotCalled();
|
|
|
|
env.currentRunner.execute();
|
|
|
|
expect(fakeReporter.reportRunnerStarting).wasCalledWith(env.currentRunner);
|
|
|
|
});
|
2009-07-09 01:33:15 +00:00
|
|
|
|
|
|
|
});
|
2009-05-29 03:02:15 +00:00
|
|
|
});
|