dwf/rva: runner that can execute multiple suites.

This commit is contained in:
pivotal
2008-12-02 11:08:12 -08:00
parent f43ba0a51c
commit 2c1d809e62
3 changed files with 119 additions and 20 deletions

View File

@@ -159,6 +159,7 @@ var describe = function (description, spec_definitions) {
description: description,
specs: [],
specIndex: 0,
finished: false,
execute: function () {
if (that.specs.length > 0) {
@@ -176,6 +177,9 @@ var describe = function (description, spec_definitions) {
currentSpec.execute();
that.waitForDone(currentSpec);
}
else {
that.finished = true;
}
},
waitForDone: function(spec) {
@@ -190,39 +194,84 @@ var describe = function (description, spec_definitions) {
}
currentSuite = that;
currentRunner.suites.push(that);
spec_definitions();
return that;
}
var currentSuite = describe('default current suite', function() {});
var currentSpec;
/*
* Jasmine constructor
*/
var jasmine_init = function () {
return {
results: []
}
}
//var jasmine_init = function () {
// return {
// results: []
// }
//}
/*
* Jasmine instance
*/
var Jasmine = jasmine_init();
//var Jasmine = jasmine_init();
var Jasmine = function() {
var that = {
suites: [],
suiteIndex: 0,
execute: function () {
if (that.suites.length > 0) {
that.next();
}
},
getCurrentSuite: function () {
return that.suites[that.suiteIndex];
},
next: function() {
if (that.suiteIndex < that.suites.length) {
var currentSuite = that.getCurrentSuite();
currentSuite.execute();
that.waitForDone(currentSuite);
}
},
waitForDone: function(suite) {
var id = setInterval(function () {
if (suite.finished) {
clearInterval(id);
that.suiteIndex++;
that.next();
}
}, 150);
}
}
currentRunner = that;
return that;
}
var currentRunner = Jasmine();
var currentSuite = describe('default current suite', function() {});
var currentSpec;
/*
* TODO:
* - add spec or description to results
//* - spec.execute needs to wait until the spec is done
//* - an async test will be killed after X ms if not done and then listed as failed with an "async fail" message of some sort
* - Suite to run tests in order, constructed with a function called describe
//* - Suite to run tests in order, constructed with a function called describe
* - Suite supports before
* - Suite supports after
* - Suite supports before_each
* - Suite supports after_each
* - Suite supports asynch
* - Suite rolls up spec results
//* - Suite supports asynch
* - Runner that runs suites in order
* - Runner supports async
* - HTML reporter