dwf/rva: added JSONReporter

This commit is contained in:
pivotal 2008-12-04 10:56:58 -08:00
parent 735ebd6c66
commit cc164257a7
5 changed files with 130 additions and 63 deletions

View File

@ -79,29 +79,38 @@
<leaf>
<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="7" column="58" selection-start="347" selection-end="347" vertical-scroll-proportion="0.13782384">
<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="7" column="61" selection-start="350" selection-end="350" vertical-scroll-proportion="0.13782384">
<state line="15" column="37" selection-start="279" selection-end="279" vertical-scroll-proportion="0.27562863">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="bootstrap.js" pinned="false" current="false" current-in-tab="false">
<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="565" column="0" selection-start="15772" selection-end="15858" vertical-scroll-proportion="0.7794971">
<state line="670" column="25" selection-start="19640" selection-end="19640" vertical-scroll-proportion="0.5093229">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="jasmine.js" pinned="false" current="true" current-in-tab="true">
<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="70" column="0" selection-start="1481" selection-end="1553" vertical-scroll-proportion="0.2205029">
<state line="285" column="5" selection-start="6014" selection-end="6014" vertical-scroll-proportion="0.43650794">
<folding />
</state>
</provider>
@ -109,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">
@ -296,6 +305,39 @@
<RUBY_DOC NAME="NUMBER" VALUE="0" />
</component>
<component name="RunManager">
<configuration default="true" type="Applet" factoryName="Applet">
<module name="" />
<option name="MAIN_CLASS_NAME" />
<option name="HTML_FILE_NAME" />
<option name="HTML_USED" value="false" />
<option name="WIDTH" value="400" />
<option name="HEIGHT" value="300" />
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
<option name="VM_PARAMETERS" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
</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="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="Application" factoryName="Application" enabled="false" merge="false">
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
@ -328,39 +370,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" />
<option name="HTML_FILE_NAME" />
<option name="HTML_USED" value="false" />
<option name="WIDTH" value="400" />
<option name="HEIGHT" value="300" />
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
<option name="VM_PARAMETERS" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
</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="&lt;template&gt;" type="WebApp" default="true" selected="false">
<Host>localhost</Host>
@ -498,15 +507,15 @@
</GetOptions>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/test/bootstrap.html">
<provider editor-type-id="HtmlPreview">
<state />
</provider>
<entry file="file://$PROJECT_DIR$/example/example.html">
<provider selected="true" editor-type-id="text-editor">
<state line="7" column="61" selection-start="350" selection-end="350" vertical-scroll-proportion="0.13782384">
<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">
@ -522,26 +531,33 @@
</state>
</provider>
</entry>
<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="7" column="58" selection-start="347" selection-end="347" vertical-scroll-proportion="0.13782384">
<folding />
</state>
</provider>
<provider editor-type-id="HtmlPreview">
<state />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/jasmine.js">
<provider selected="true" editor-type-id="text-editor">
<state line="8" column="7" selection-start="355" selection-end="355" vertical-scroll-proportion="0.15751295">
<state line="285" column="5" selection-start="6014" selection-end="6014" vertical-scroll-proportion="0.43650794">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/json_reporter.js">
<provider selected="true" editor-type-id="text-editor">
<state line="15" column="37" selection-start="279" selection-end="279" vertical-scroll-proportion="0.27562863">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
<provider selected="true" editor-type-id="text-editor">
<state line="565" column="0" selection-start="15772" selection-end="15858" vertical-scroll-proportion="0.7794971">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/jasmine.js">
<provider selected="true" editor-type-id="text-editor">
<state line="70" column="0" selection-start="1481" selection-end="1553" vertical-scroll-proportion="0.2205029">
<state line="670" column="25" selection-start="19640" selection-end="19640" vertical-scroll-proportion="0.5093229">
<folding />
</state>
</provider>

View File

@ -279,14 +279,24 @@ var Runner = function () {
that.suites = that.actions;
that.results.description = 'All Jasmine Suites';
that.finishCallback = function () {
if (that.reporter) {
that.reporter.addResults(that.results);
that.reporter.report();
}
}
Jasmine = that;
return that;
}
var JasmineReporters = {};
var Jasmine = Runner();
var currentSuite;
var currentSpec;
/*
* TODO:
//* - add spec or description to results

17
lib/json_reporter.js Normal file
View File

@ -0,0 +1,17 @@
JasmineReporters.JSON = function () {
var that = {
results: {},
addResults: function (results) {
that.results = results;
},
report: function () {
return Object.toJSON(that.results);
}
}
return that;
}
Jasmine.reporter = JasmineReporters.JSON();

View File

@ -5,6 +5,7 @@
<title>Jasmine Tests</title>
<script type="text/javascript" src="prototype-1.6.0.3.js"></script>
<script type="text/javascript" src="../lib/jasmine.js"></script>
<script type="text/javascript" src="../lib/json_reporter.js"></script>
<link type="text/css" rel="stylesheet" href="../lib/jasmine.css"/>
<script type="text/javascript" src="bootstrap.js"></script>
</head>

37
test/bootstrap.js vendored
View File

@ -544,15 +544,13 @@ var testRunner = function() {
var testRunnerFinishCallback = function () {
var runner = Runner();
var foo = 0;
var s
runner.finish();
reporter.test((runner.finishCallback === undefined),
"Runner finish callback was defined");
reporter.test((runner.finished === true),
"Runner finished flag was not set.");
runner.finishCallback = function () {
foo++;
}
@ -561,8 +559,6 @@ var testRunnerFinishCallback = function () {
reporter.test((runner.finished === true),
"Runner finished flag was not set.");
reporter.test((runner.finishCallback !== undefined),
"Runner finish callback was not defined");
reporter.test((foo === 1),
"Runner finish callback was not called");
}
@ -619,7 +615,7 @@ var testNestedResults = function () {
"Branch Results should have 2 failed, has " + branchResults.failedCount);
}
var testReporting = function () {
var testResults = function () {
var runner = Runner();
describe('one suite description', function () {
it('should be a test', function() {
@ -652,6 +648,32 @@ var testReporting = function () {
}
var testJSONReporter = function () {
var runner = Runner();
describe('one suite description', function () {
it('should be a test', function() {
runs(function () {
this.expects_that(true).should_equal(true);
});
});
});
runner.reporter = JasmineReporters.JSON();
reporter.test((runner.reporter !== undefined),
"Runner's reporter is undefined");
reporter.test((runner.finishCallback !== 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"}';
setTimeout(function() {
reporter.test((runner.reporter.report() === expectedJSONString),
'Jasmine Reporter does not have the expected report, has: ' + runner.reporter.report());
}, 500);
}
var runTests = function () {
$('spinner').show();
@ -666,7 +688,8 @@ var runTests = function () {
testRunner();
testRunnerFinishCallback();
testNestedResults();
testReporting();
testResults();
testJSONReporter();
setTimeout(function() {
$('spinner').hide();