Fix 'doubled' test runs in test runner

This commit is contained in:
ragaskar
2009-09-01 21:21:54 -07:00
parent b9ee6a9119
commit 50134eb1ac
20 changed files with 288 additions and 272 deletions

View File

@@ -11,27 +11,27 @@ jasmine.JsApiReporter = function() {
jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) {
this.started = true;
for (var i = 0; i < runner.suites.length; i++) {
var suite = runner.suites[i];
var suites = runner.getAllSuites();
for (var i = 0; i < suites.length; i++) {
var suite = suites[i];
this.suites.push(this.summarize_(suite));
}
};
jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
var isSuite = suiteOrSpec instanceof jasmine.Suite
var summary = {
id: suiteOrSpec.id,
name: suiteOrSpec.description,
type: suiteOrSpec instanceof jasmine.Suite ? 'suite' : 'spec',
type: isSuite ? 'suite' : 'spec',
children: []
};
if (suiteOrSpec.specs) {
for (var i = 0; i < suiteOrSpec.specs.length; i++) {
summary.children.push(this.summarize_(suiteOrSpec.specs[i]));
if (isSuite) {
var specs = suiteOrSpec.getSpecs();
for (var i = 0; i < specs.length; i++) {
summary.children.push(this.summarize_(specs[i]));
}
}
return summary;
};

View File

@@ -52,15 +52,20 @@ jasmine.Suite.prototype.getResults = function() {
jasmine.Suite.prototype.add = function(block) {
if (block instanceof jasmine.Suite) {
this.env.currentRunner.addSuite(block);
} else {
this.specs.push(block);
}
this.specs.push(block);
this.queue.add(block);
};
jasmine.Suite.prototype.specCount = function(block) {
jasmine.Suite.prototype.specCount = function() {
return this.specs.length;
};
jasmine.Suite.prototype.getSpecs = function() {
return this.specs;
};
jasmine.Suite.prototype.execute = function(onComplete) {
var self = this;
this.queue.start(function () {