dwf/rva: results now propagated up.

This commit is contained in:
pivotal 2008-12-02 13:59:39 -08:00
parent 42eeab1cdb
commit 1df1de2bb7
3 changed files with 161 additions and 41 deletions

View File

@ -80,7 +80,7 @@
<file leaf-file-name="bootstrap.html" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/bootstrap.html">
<provider selected="true" editor-type-id="text-editor">
<state line="15" column="26" selection-start="541" selection-end="541" vertical-scroll-proportion="0.29533678">
<state line="15" column="26" selection-start="541" selection-end="541" vertical-scroll-proportion="0.47420964">
<folding />
</state>
</provider>
@ -92,7 +92,7 @@
<file leaf-file-name="bootstrap.js" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
<provider selected="true" editor-type-id="text-editor">
<state line="333" column="14" selection-start="9162" selection-end="9162" vertical-scroll-proportion="1.0473888">
<state line="519" column="0" selection-start="14833" selection-end="14833" vertical-scroll-proportion="0.41459626">
<folding />
</state>
</provider>
@ -101,7 +101,7 @@
<file leaf-file-name="test.css" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/test.css">
<provider selected="true" editor-type-id="text-editor">
<state line="5" column="0" selection-start="118" selection-end="118" vertical-scroll-proportion="0.09187621">
<state line="5" column="0" selection-start="118" selection-end="118" vertical-scroll-proportion="0.14179105">
<folding />
</state>
</provider>
@ -110,7 +110,7 @@
<file leaf-file-name="jasmine.js" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/lib/jasmine.js">
<provider selected="true" editor-type-id="text-editor">
<state line="230" column="0" selection-start="4905" selection-end="4938" vertical-scroll-proportion="0.7703928">
<state line="265" column="30" selection-start="5651" selection-end="5651" vertical-scroll-proportion="0.5437202">
<folding />
</state>
</provider>
@ -313,7 +313,7 @@
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="7" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.21091811" order="0" />
<window_info id="RDoc" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="1" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.32933578" order="1" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="1" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" order="6" />
@ -434,7 +434,7 @@
</entry>
<entry file="file://$PROJECT_DIR$/test/bootstrap.html">
<provider selected="true" editor-type-id="text-editor">
<state line="15" column="26" selection-start="541" selection-end="541" vertical-scroll-proportion="0.29533678">
<state line="15" column="26" selection-start="541" selection-end="541" vertical-scroll-proportion="0.47420964">
<folding />
</state>
</provider>
@ -444,21 +444,21 @@
</entry>
<entry file="file://$PROJECT_DIR$/test/test.css">
<provider selected="true" editor-type-id="text-editor">
<state line="5" column="0" selection-start="118" selection-end="118" vertical-scroll-proportion="0.09187621">
<state line="5" column="0" selection-start="118" selection-end="118" vertical-scroll-proportion="0.14179105">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
<provider selected="true" editor-type-id="text-editor">
<state line="333" column="14" selection-start="9162" selection-end="9162" vertical-scroll-proportion="1.0473888">
<state line="519" column="0" selection-start="14833" selection-end="14833" vertical-scroll-proportion="0.41459626">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/jasmine.js">
<provider selected="true" editor-type-id="text-editor">
<state line="230" column="0" selection-start="4905" selection-end="4938" vertical-scroll-proportion="0.7703928">
<state line="265" column="30" selection-start="5651" selection-end="5651" vertical-scroll-proportion="0.5437202">
<folding />
</state>
</provider>

View File

@ -23,6 +23,11 @@ var actionCollection = function () {
actions: [],
index: 0,
finished: false,
results: nestedResults(),
report: function (result) {
that.results.push(result);
},
execute: function () {
if (that.actions.length > 0) {
@ -48,6 +53,7 @@ var actionCollection = function () {
var id = setInterval(function () {
if (action.finished) {
clearInterval(id);
that.report(action.results);
that.index++;
that.next();
}
@ -68,7 +74,7 @@ var actionCollection = function () {
Matchers = function (actual, results) {
this.actual = actual;
this.passing_message = 'Passed.'
this.results = results || [];
this.results = results || nestedResults();
}
Matchers.method('report', function (result, failing_message) {
@ -117,6 +123,33 @@ var queuedFunction = function(func, timeout, spec) {
return that;
}
var nestedResults = function() {
var that = {
totalCount: 0,
passedCount: 0,
failedCount: 0,
results: [],
push: function(result) {
if (result.results) {
that.totalCount += result.totalCount;
that.passedCount += result.passedCount;
that.failedCount += result.failedCount;
} else {
that.totalCount++;
if (result.passed) {
that.passedCount++;
} else {
that.failedCount++;
}
}
that.results.push(result);
}
}
return that;
}
var it = function (description, func) {
var that = {
@ -124,9 +157,12 @@ var it = function (description, func) {
queue: [],
currentTimeout: 0,
finished: false,
suite: {next:function() {
}},
results: [],
// suite: {
// next: function() {
// }},
results: nestedResults(),
expects_that: function (actual) {
return new Matchers(actual, that.results);
@ -208,6 +244,7 @@ var Jasmine = function () {
var that = actionCollection();
that.suites = that.actions;
currentRunner = that;
return that;
}
@ -227,7 +264,7 @@ var currentSpec;
* - Suite supports after
* - Suite supports before_each
* - Suite supports after_each
* - Suite rolls up spec results
//* - Suite rolls up spec results
//* - Suite supports asynch
//* - Runner that runs suites in order
// * - Runner supports async

125
test/bootstrap.js vendored
View File

@ -31,7 +31,7 @@ var reporter = function () {
summary: function () {
summary = new Element('p', {'class': ((fails > 0) ? 'fail_in_summary' : '') });
summary.innerHTML = total + ' tests, ' + passes + ' passing, ' + fails + ' failed.';
summary.innerHTML = total + ' expectations, ' + passes + ' passing, ' + fails + ' failed.';
var summaryElement = $('results_summary');
summaryElement.appendChild(summary);
@ -102,9 +102,9 @@ var testSpecs = function () {
another_spec.execute();
another_spec.done = true;
reporter.test((another_spec.results.length == 1),
reporter.test((another_spec.results.results.length == 1),
"Results aren't there after a spec was executed");
reporter.test((another_spec.results[0].passed == true),
reporter.test((another_spec.results.results[0].passed == true),
"Results has a result, but it's true");
var yet_another_spec = it('spec with failing expectation').runs(function () {
@ -114,7 +114,7 @@ var testSpecs = function () {
yet_another_spec.execute();
yet_another_spec.done = true;
reporter.test((yet_another_spec.results[0].passed == false),
reporter.test((yet_another_spec.results.results[0].passed == false),
"Expectation that failed, passed");
var yet_yet_another_spec = it('spec with multiple assertions').runs(function () {
@ -127,7 +127,7 @@ var testSpecs = function () {
yet_yet_another_spec.execute();
yet_yet_another_spec.done = true;
reporter.test((yet_yet_another_spec.results.length == 2),
reporter.test((yet_yet_another_spec.results.results.length == 2),
"Spec doesn't support multiple expectations");
}
@ -154,9 +154,9 @@ var testAsyncSpecs = function () {
a_spec.execute();
reporter.test((a_spec.results.length === 1),
reporter.test((a_spec.results.results.length === 1),
'No call to waits(): Spec queue did not run all functions');
reporter.test((a_spec.results[0].passed === true),
reporter.test((a_spec.results.results[0].passed === true),
'No call to waits(): Queued expectation failed');
foo = 0;
@ -172,10 +172,10 @@ var testAsyncSpecs = function () {
var mockSuite = {
next: function() {
reporter.test((a_spec.results.length === 1),
reporter.test((a_spec.results.results.length === 1),
'Calling waits(): Spec queue did not run all functions');
reporter.test((a_spec.results[0].passed === true),
reporter.test((a_spec.results.results[0].passed === true),
'Calling waits(): Queued expectation failed');
}
};
@ -203,9 +203,9 @@ var testAsyncSpecs = function () {
next: function() {
reporter.test((another_spec.queue.length === 3),
'Calling 2 waits(): Spec queue was less than expected length');
reporter.test((another_spec.results.length === 1),
reporter.test((another_spec.results.results.length === 1),
'Calling 2 waits(): Spec queue did not run all functions');
reporter.test((another_spec.results[0].passed === true),
reporter.test((another_spec.results.results[0].passed === true),
'Calling 2 waits(): Queued expectation failed');
}
};
@ -229,9 +229,9 @@ var testAsyncSpecs = function () {
reporter.test((yet_another_spec.queue.length === 2),
'Calling 2 waits(): Spec queue was less than expected length');
reporter.test((yet_another_spec.results.length === 1),
reporter.test((yet_another_spec.results.results.length === 1),
'Calling 2 waits(): Spec queue did not run all functions');
reporter.test((yet_another_spec.results[0].passed === false),
reporter.test((yet_another_spec.results.results[0].passed === false),
'Calling 2 waits(): Queued expectation failed');
}
};
@ -263,9 +263,9 @@ var testAsyncSpecsWithMockSuite = function () {
next: function () {
reporter.test((another_spec.queue.length === 3),
'Calling 2 waits(): Spec queue was less than expected length');
reporter.test((another_spec.results.length === 1),
reporter.test((another_spec.results.results.length === 1),
'Calling 2 waits(): Spec queue did not run all functions');
reporter.test((another_spec.results[0].passed === true),
reporter.test((another_spec.results.results[0].passed === true),
'Calling 2 waits(): Queued expectation failed');
}
};
@ -330,7 +330,6 @@ var testSuites = function () {
reporter.test((suite.specs[0].queue.length === 2),
"Suite's spec did not get 2 functions pushed");
var foo = 0;
suite = describe('one suite description', function () {
it('should be a test with queuedFunctions', function() {
@ -390,11 +389,11 @@ var testSpecScope = function () {
setTimeout(function () {
reporter.test((suite.specs[0].foo === 2),
"Spec does not maintain scope in between functions");
reporter.test((suite.specs[0].results.length === 2),
reporter.test((suite.specs[0].results.results.length === 2),
"Spec did not get results for all expectations");
reporter.test((suite.specs[0].results[0].passed === false),
reporter.test((suite.specs[0].results.results[0].passed === false),
"Spec did not return false for a failed expectation");
reporter.test((suite.specs[0].results[1].passed === true),
reporter.test((suite.specs[0].results.results[1].passed === true),
"Spec did not return true for a passing expectation");
}, 1000);
}
@ -441,13 +440,95 @@ var testRunner = function() {
setTimeout(function () {
reporter.test((runner.suites.length === 2),
"Runner expected two suites");
reporter.test((runner.suites[0].specs[0].results[0].passed === true),
reporter.test((runner.suites[0].specs[0].results.results[0].passed === true),
"Runner should have run specs in first suite");
reporter.test((runner.suites[1].specs[0].results[0].passed === false),
reporter.test((runner.suites[1].specs[0].results.results[0].passed === false),
"Runner should have run specs in second suite");
}, 1000);
}
var testNestedResults = function () {
// Leaf case
var results = nestedResults();
results.push({passed: true, message: 'Passed.'});
reporter.test((results.results.length === 1),
"nestedResults.push didn't work");
reporter.test((results.totalCount === 1),
"nestedResults.push didn't increment totalCount");
reporter.test((results.passedCount === 1),
"nestedResults.push didn't increment passedCount");
reporter.test((results.failedCount === 0),
"nestedResults.push didn't ignore failedCount");
results.push({passed: false, message: 'FAIL.'});
reporter.test((results.results.length === 2),
"nestedResults.push didn't work");
reporter.test((results.totalCount === 2),
"nestedResults.push didn't increment totalCount");
reporter.test((results.passedCount === 1),
"nestedResults.push didn't ignore passedCount");
reporter.test((results.failedCount === 1),
"nestedResults.push didn't increment failedCount");
// Branch case
var leafResultsOne = nestedResults();
leafResultsOne.push({passed: true, message: ''});
leafResultsOne.push({passed: false, message: ''});
var leafResultsTwo = nestedResults();
leafResultsTwo.push({passed: true, message: ''});
leafResultsTwo.push({passed: false, message: ''});
var branchResults = nestedResults();
branchResults.push(leafResultsOne);
branchResults.push(leafResultsTwo);
reporter.test((branchResults.results.length === 2),
"Branch Results should have 2 nestedResults, has " + branchResults.results.length);
reporter.test((branchResults.totalCount === 4),
"Branch Results should have 4 results, has " + branchResults.totalCount);
reporter.test((branchResults.passedCount === 2),
"Branch Results should have 2 passed, has " + branchResults.passedCount);
reporter.test((branchResults.failedCount === 2),
"Branch Results should have 2 failed, has " + branchResults.failedCount);
}
var testReporting = function () {
var 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.results.totalCount === 2),
'Expectation count should be 2, but was ' + runner.results.totalCount);
reporter.test((runner.results.passedCount === 1),
'Expectation Passed count should be 1, but was ' + runner.results.passedCount);
reporter.test((runner.results.failedCount === 1),
'Expectation Failed count should be 1, but was ' + runner.results.failedCount);
}, 1000);
}
var runTests = function () {
$('spinner').show();
@ -459,6 +540,8 @@ var runTests = function () {
testSuites();
testSpecScope();
testRunner();
testNestedResults();
testReporting();
setTimeout(function() {
$('spinner').hide();