dwf/rva: Added Incremental Reporter, refactored abstract reporter class, added tests! 78!!!
This commit is contained in:
parent
8ee209585d
commit
80e1d6b6e8
116
jasmine.iws
116
jasmine.iws
@ -79,20 +79,20 @@
|
||||
<leaf>
|
||||
<file leaf-file-name="bootstrap.html" pinned="false" current="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/test/bootstrap.html">
|
||||
<provider editor-type-id="HtmlPreview">
|
||||
<state />
|
||||
</provider>
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="29" column="0" selection-start="991" selection-end="991" vertical-scroll-proportion="0.5709845">
|
||||
<state line="29" column="63" selection-start="1054" selection-end="1054" vertical-scroll-proportion="0.5709845">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
<provider editor-type-id="HtmlPreview">
|
||||
<state />
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="json_reporter.js" pinned="false" current="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/json_reporter.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="2" column="25" selection-start="87" selection-end="87" vertical-scroll-proportion="0.036750484">
|
||||
<state line="5" column="55" selection-start="187" selection-end="187" vertical-scroll-proportion="0.09187621">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
@ -101,7 +101,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="714" column="25" selection-start="21145" selection-end="21145" vertical-scroll-proportion="0.85083413">
|
||||
<state line="690" column="388" selection-start="20624" selection-end="20624" vertical-scroll-proportion="0.27281648">
|
||||
<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="292" column="26" selection-start="6082" selection-end="6082" vertical-scroll-proportion="0.3617021">
|
||||
<state line="292" column="29" selection-start="6206" selection-end="6206" vertical-scroll-proportion="0.17063493">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
@ -118,14 +118,14 @@
|
||||
</file>
|
||||
<file leaf-file-name="example.html" pinned="false" current="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/example/example.html">
|
||||
<provider editor-type-id="HtmlPreview">
|
||||
<state />
|
||||
</provider>
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="8" column="7" selection-start="355" selection-end="355" vertical-scroll-proportion="0.15751295">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
<provider editor-type-id="HtmlPreview">
|
||||
<state />
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="jasmine.css" pinned="false" current="false" current-in-tab="false">
|
||||
@ -305,6 +305,40 @@
|
||||
<RUBY_DOC NAME="NUMBER" VALUE="0" />
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<configuration default="true" type="RubyRunConfigurationType" factoryName="Ruby test">
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_CLASS_NAME" VALUE="" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_METHOD_NAME" VALUE="" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift)" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="MODULE_NAME" VALUE="" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="INHERITANCE_CHECK_DISABLED" VALUE="false" />
|
||||
</configuration>
|
||||
<configuration default="true" type="Remote" factoryName="Remote">
|
||||
<option name="USE_SOCKET_TRANSPORT" value="true" />
|
||||
<option name="SERVER_MODE" value="false" />
|
||||
<option name="SHMEM_ADDRESS" value="javadebug" />
|
||||
<option name="HOST" value="localhost" />
|
||||
<option name="PORT" value="5005" />
|
||||
</configuration>
|
||||
<configuration default="true" type="Application" factoryName="Application" enabled="false" merge="false">
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="VM_PARAMETERS" />
|
||||
<option name="PROGRAM_PARAMETERS" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
||||
<option name="ENABLE_SWING_INSPECTOR" value="false" />
|
||||
<option name="ENV_VARIABLES" />
|
||||
<option name="PASS_PARENT_ENVS" value="true" />
|
||||
<module name="" />
|
||||
<envs />
|
||||
</configuration>
|
||||
<configuration default="true" type="JUnit" factoryName="JUnit" enabled="false" merge="false">
|
||||
<module name="" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
@ -324,20 +358,6 @@
|
||||
</option>
|
||||
<envs />
|
||||
</configuration>
|
||||
<configuration default="true" type="RubyRunConfigurationType" factoryName="Ruby test">
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_CLASS_NAME" VALUE="" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_METHOD_NAME" VALUE="" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift)" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="MODULE_NAME" VALUE="" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
|
||||
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="INHERITANCE_CHECK_DISABLED" VALUE="false" />
|
||||
</configuration>
|
||||
<configuration default="true" type="Applet" factoryName="Applet">
|
||||
<module name="" />
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
@ -350,26 +370,6 @@
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
||||
</configuration>
|
||||
<configuration default="true" type="Application" factoryName="Application" enabled="false" merge="false">
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="VM_PARAMETERS" />
|
||||
<option name="PROGRAM_PARAMETERS" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
||||
<option name="ENABLE_SWING_INSPECTOR" value="false" />
|
||||
<option name="ENV_VARIABLES" />
|
||||
<option name="PASS_PARENT_ENVS" value="true" />
|
||||
<module name="" />
|
||||
<envs />
|
||||
</configuration>
|
||||
<configuration default="true" type="Remote" factoryName="Remote">
|
||||
<option name="USE_SOCKET_TRANSPORT" value="true" />
|
||||
<option name="SERVER_MODE" value="false" />
|
||||
<option name="SHMEM_ADDRESS" value="javadebug" />
|
||||
<option name="HOST" value="localhost" />
|
||||
<option name="PORT" value="5005" />
|
||||
</configuration>
|
||||
<list size="0" />
|
||||
<configuration name="<template>" type="WebApp" default="true" selected="false">
|
||||
<Host>localhost</Host>
|
||||
@ -507,15 +507,25 @@
|
||||
</GetOptions>
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/example/example.html">
|
||||
<entry file="file://$PROJECT_DIR$/test/bootstrap.html">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="29" column="63" selection-start="1054" selection-end="1054" vertical-scroll-proportion="0.5709845">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
<provider editor-type-id="HtmlPreview">
|
||||
<state />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/example.html">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="8" column="7" selection-start="355" selection-end="355" vertical-scroll-proportion="0.15751295">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
<provider editor-type-id="HtmlPreview">
|
||||
<state />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/jasmine.css">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
@ -533,31 +543,21 @@
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/jasmine.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="292" column="26" selection-start="6082" selection-end="6082" vertical-scroll-proportion="0.3617021">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/bootstrap.html">
|
||||
<provider editor-type-id="HtmlPreview">
|
||||
<state />
|
||||
</provider>
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="29" column="0" selection-start="991" selection-end="991" vertical-scroll-proportion="0.5709845">
|
||||
<state line="292" column="29" selection-start="6206" selection-end="6206" vertical-scroll-proportion="0.17063493">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/json_reporter.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="2" column="25" selection-start="87" selection-end="87" vertical-scroll-proportion="0.036750484">
|
||||
<state line="5" column="55" selection-start="187" selection-end="187" vertical-scroll-proportion="0.09187621">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="714" column="25" selection-start="21145" selection-end="21145" vertical-scroll-proportion="0.85083413">
|
||||
<state line="690" column="388" selection-start="20624" selection-end="20624" vertical-scroll-proportion="0.27281648">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -58,7 +58,7 @@ var nestedResults = function() {
|
||||
*
|
||||
**/
|
||||
var actionCollection = function () {
|
||||
var that = {
|
||||
var that = {
|
||||
actions: [],
|
||||
index: 0,
|
||||
finished: false,
|
||||
@ -202,7 +202,15 @@ var it = function (description, func) {
|
||||
that.currentTimeout = 0;
|
||||
},
|
||||
|
||||
finishCallback: function () {
|
||||
if (Jasmine.reporter) {
|
||||
Jasmine.reporter.addSpecResults(that.results);
|
||||
Jasmine.reporter.report();
|
||||
}
|
||||
},
|
||||
|
||||
finish: function() {
|
||||
that.finishCallback();
|
||||
that.finished = true;
|
||||
},
|
||||
|
||||
|
@ -1,26 +1,44 @@
|
||||
JasmineReporters.JSON = function (elementId) {
|
||||
JasmineReporters.reporter = function (elementId) {
|
||||
var that = {
|
||||
elementId: elementId,
|
||||
results: {},
|
||||
element: document.getElementById(elementId),
|
||||
output: '',
|
||||
|
||||
addResults: function (results) {
|
||||
that.results = results;
|
||||
},
|
||||
addResults: function (results) { that.output = ''; },
|
||||
|
||||
addSpecResults: function (results) { that.output = ''; },
|
||||
|
||||
report: function () {
|
||||
var output = Object.toJSON(that.results);
|
||||
|
||||
if (that.elementId) {
|
||||
var element = document.getElementById(that.elementId);
|
||||
if (element) {
|
||||
element.innerHTML = output;
|
||||
}
|
||||
if (that.element) {
|
||||
that.element.innerHTML += that.output;
|
||||
}
|
||||
return output;
|
||||
return that.output;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: throw if no element?
|
||||
if (that.element) {
|
||||
that.element.innerHTML = '';
|
||||
}
|
||||
|
||||
return that;
|
||||
}
|
||||
|
||||
Jasmine.reporter = JasmineReporters.JSON();
|
||||
JasmineReporters.JSON = function (elementId) {
|
||||
var that = JasmineReporters.reporter(elementId);
|
||||
|
||||
that.addResults = function (results) {
|
||||
that.output = Object.toJSON(results);
|
||||
}
|
||||
|
||||
return that;
|
||||
}
|
||||
|
||||
JasmineReporters.IncrementalJSON = function (elementId) {
|
||||
var that = JasmineReporters.reporter(elementId);
|
||||
|
||||
that.addSpecResults = function (results) {
|
||||
that.output = Object.toJSON(results);
|
||||
}
|
||||
|
||||
return that;
|
||||
}
|
@ -27,6 +27,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div style="display:none" id="json_reporter_results"></div>
|
||||
<div style="display:none" id="json_reporter_results_incremental"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
60
test/bootstrap.js
vendored
60
test/bootstrap.js
vendored
@ -91,7 +91,8 @@ var testMatchersReporting = function () {
|
||||
}
|
||||
|
||||
var testSpecs = function () {
|
||||
var currentSuite = describe('default current suite', function() {});
|
||||
var currentSuite = describe('default current suite', function() {
|
||||
});
|
||||
|
||||
var spec = it('new spec');
|
||||
reporter.test((spec.description == 'new spec'),
|
||||
@ -549,7 +550,7 @@ var testRunnerFinishCallback = function () {
|
||||
runner.finish();
|
||||
|
||||
reporter.test((runner.finished === true),
|
||||
"Runner finished flag was not set.");
|
||||
"Runner finished flag was not set.");
|
||||
|
||||
runner.finishCallback = function () {
|
||||
foo++;
|
||||
@ -558,13 +559,12 @@ var testRunnerFinishCallback = function () {
|
||||
runner.finish();
|
||||
|
||||
reporter.test((runner.finished === true),
|
||||
"Runner finished flag was not set.");
|
||||
"Runner finished flag was not set.");
|
||||
reporter.test((foo === 1),
|
||||
"Runner finish callback was not called");
|
||||
"Runner finish callback was not called");
|
||||
}
|
||||
|
||||
|
||||
|
||||
var testNestedResults = function () {
|
||||
|
||||
// Leaf case
|
||||
@ -650,7 +650,7 @@ var testResults = function () {
|
||||
|
||||
var testJSONReporter = function () {
|
||||
var runner = Runner();
|
||||
describe('one suite description', function () {
|
||||
describe('Suite for JSON Reporter, NO DOM', function () {
|
||||
it('should be a test', function() {
|
||||
runs(function () {
|
||||
this.expects_that(true).should_equal(true);
|
||||
@ -661,22 +661,22 @@ var testJSONReporter = function () {
|
||||
runner.reporter = JasmineReporters.JSON();
|
||||
|
||||
reporter.test((runner.reporter !== undefined),
|
||||
"Runner's reporter is undefined");
|
||||
"Runner's reporter is undefined");
|
||||
reporter.test((runner.finishCallback !== undefined),
|
||||
"Runner's finishCallback is undefined");
|
||||
"Runner's finishCallback is undefined");
|
||||
|
||||
runner.execute();
|
||||
|
||||
expectedJSONString = '{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"passed": true, "message": "Passed."}], "description": "should be a test"}], "description": "one suite description"}], "description": "All Jasmine Suites"}';
|
||||
var expectedJSONString = '{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"passed": true, "message": "Passed."}], "description": "should be a test"}], "description": "Suite for JSON Reporter, NO DOM"}], "description": "All Jasmine Suites"}';
|
||||
setTimeout(function() {
|
||||
reporter.test((runner.reporter.report() === expectedJSONString),
|
||||
'Jasmine Reporter does not have the expected report, has: ' + runner.reporter.report());
|
||||
reporter.test((runner.reporter.output === expectedJSONString),
|
||||
'Jasmine Reporter with No DOM does not have the expected report.<br /> <b>Expected:</b><br /> ' + expectedJSONString + '<br /><b>Got:</b><br /> ' + runner.reporter.output);
|
||||
}, 500);
|
||||
}
|
||||
|
||||
var testJSONReporterWithDOM = function () {
|
||||
var runner = Runner();
|
||||
describe('one suite description', function () {
|
||||
describe('Suite for JSON Reporter/DOM', function () {
|
||||
it('should be a test', function() {
|
||||
runs(function () {
|
||||
this.expects_that(true).should_equal(true);
|
||||
@ -688,14 +688,43 @@ var testJSONReporterWithDOM = function () {
|
||||
|
||||
runner.execute();
|
||||
|
||||
expectedJSONString = '{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"passed": true, "message": "Passed."}], "description": "should be a test"}], "description": "one suite description"}], "description": "All Jasmine Suites"}';
|
||||
var expectedJSONString = '{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"passed": true, "message": "Passed."}], "description": "should be a test"}], "description": "Suite for JSON Reporter/DOM"}], "description": "All Jasmine Suites"}';
|
||||
setTimeout(function() {
|
||||
reporter.test((document.getElementById('json_reporter_results').innerHTML === expectedJSONString),
|
||||
'Jasmine Reporter did not output the string to the DOM');
|
||||
|
||||
'Jasmine Reporter did not output the string to the DOM, got:' + document.getElementById('json_reporter_results').innerHTML);
|
||||
}, 500);
|
||||
}
|
||||
|
||||
var testJSONReporterWithIncrementalSpecReports = function() {
|
||||
setTimeout( function () {
|
||||
var runner = Runner();
|
||||
describe('Suite for Incremental JSON Reporter/DOM', function () {
|
||||
it('should be a test', function() {
|
||||
runs(function () {
|
||||
this.expects_that(true).should_equal(true);
|
||||
});
|
||||
});
|
||||
it('should be a failing test', function() {
|
||||
runs(function () {
|
||||
this.expects_that(false).should_equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
runner.reporter = JasmineReporters.IncrementalJSON('json_reporter_results_incremental');
|
||||
runner.execute();
|
||||
var expectedJSONString = '{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"passed": true, "message": "Passed."}], "description": "should be a test"}{"totalCount": 1, "passedCount": 0, "failedCount": 1, "results": [{"passed": false, "message": "Expected true but got false."}], "description": "should be a failing test"}'
|
||||
|
||||
setTimeout(function() {
|
||||
reporter.test((document.getElementById('json_reporter_results_incremental').innerHTML === expectedJSONString),
|
||||
'Jasmine Incremental Reporter did not output the correct string to the DOM, got ' + document.getElementById('json_reporter_results_incremental').innerHTML);
|
||||
|
||||
}, 500);
|
||||
}, 2500);
|
||||
|
||||
}
|
||||
|
||||
|
||||
var runTests = function () {
|
||||
$('spinner').show();
|
||||
|
||||
@ -713,6 +742,7 @@ var runTests = function () {
|
||||
testResults();
|
||||
testJSONReporter();
|
||||
testJSONReporterWithDOM();
|
||||
testJSONReporterWithIncrementalSpecReports();
|
||||
|
||||
setTimeout(function() {
|
||||
$('spinner').hide();
|
||||
|
Loading…
Reference in New Issue
Block a user