dwf/rva: runner that can execute multiple suites.
This commit is contained in:
parent
f43ba0a51c
commit
2c1d809e62
|
@ -92,7 +92,7 @@
|
|||
<file leaf-file-name="bootstrap.js" pinned="false" current="true" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="411" column="0" selection-start="11018" selection-end="11018" vertical-scroll-proportion="0.7427466">
|
||||
<state line="465" column="7" selection-start="12461" selection-end="12461" vertical-scroll-proportion="0.9632495">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -110,7 +110,7 @@
|
|||
<file leaf-file-name="jasmine.js" pinned="false" current="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/jasmine.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="199" column="0" selection-start="4076" selection-end="4076" vertical-scroll-proportion="1.8949951">
|
||||
<state line="238" column="9" selection-start="4765" selection-end="4765" vertical-scroll-proportion="0.5599194">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -451,14 +451,14 @@
|
|||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/jasmine.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="199" column="0" selection-start="4076" selection-end="4076" vertical-scroll-proportion="1.8949951">
|
||||
<state line="238" column="9" selection-start="4765" selection-end="4765" vertical-scroll-proportion="0.5599194">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="411" column="0" selection-start="11018" selection-end="11018" vertical-scroll-proportion="0.7427466">
|
||||
<state line="465" column="7" selection-start="12461" selection-end="12461" vertical-scroll-proportion="0.9632495">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -399,16 +399,66 @@ var testSpecScope = function () {
|
|||
}, 1000);
|
||||
}
|
||||
|
||||
|
||||
var testRunner = function() {
|
||||
|
||||
var runner = Jasmine();
|
||||
describe('one suite description', function () {
|
||||
it('should be a test');
|
||||
});
|
||||
reporter.test((runner.suites.length === 1),
|
||||
"Runner expected one suite");
|
||||
|
||||
runner = Jasmine();
|
||||
describe('one suite description', function () {
|
||||
it('should be a test');
|
||||
});
|
||||
describe('another suite description', function () {
|
||||
it('should be a test');
|
||||
});
|
||||
reporter.test((runner.suites.length === 2),
|
||||
"Runner expected two suites");
|
||||
|
||||
runner = Jasmine();
|
||||
describe('one suite description', function () {
|
||||
it('should be a test', function() {
|
||||
runs(function () {
|
||||
this.expects_that(true).should_equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('another suite description', function () {
|
||||
it('should be another test', function() {
|
||||
runs(function () {
|
||||
this.expects_that(true).should_equal(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
runner.execute();
|
||||
|
||||
setTimeout(function () {
|
||||
reporter.test((runner.suites.length === 2),
|
||||
"Runner expected two suites");
|
||||
reporter.test((runner.suites[0].specs[0].results[0].passed === true),
|
||||
"Runner should have run specs in first suite");
|
||||
reporter.test((runner.suites[1].specs[0].results[0].passed === false),
|
||||
"Runner should have run specs in second suite");
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
var runTests = function () {
|
||||
$('spinner').show();
|
||||
|
||||
testMatchersComparisons();
|
||||
testMatchersReporting();
|
||||
testSpecs();
|
||||
testAsyncSpecs();
|
||||
testAsyncSpecsWithMockSuite();
|
||||
testSuites();
|
||||
testSpecScope();
|
||||
testMatchersReporting();
|
||||
testSpecs();
|
||||
testAsyncSpecs();
|
||||
testAsyncSpecsWithMockSuite();
|
||||
testSuites();
|
||||
testSpecScope();
|
||||
testRunner();
|
||||
|
||||
setTimeout(function() {
|
||||
$('spinner').hide();
|
||||
|
|
Loading…
Reference in New Issue