headless-squirrel 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +55 -0
- data/Rakefile +27 -0
- data/bin/jstest +10 -0
- data/lib/headless_squirrel.rb +2 -0
- data/lib/headless_squirrel/console.rb +24 -0
- data/lib/headless_squirrel/runner.rb +70 -0
- data/lib/headless_squirrel/test.rb +17 -0
- data/lib/headless_squirrel/test_case.rb +158 -0
- data/test/fixtures/a_unit_test.html +27 -0
- data/test/fixtures/a_unit_test.js +22 -0
- data/test/fixtures/syntax_error.html +27 -0
- data/test/fixtures/syntax_error.js +5 -0
- data/test/fixtures/type_error.html +27 -0
- data/test/fixtures/type_error.js +1 -0
- data/test/regression/prototype/unit/ajax_test.html +29 -0
- data/test/regression/prototype/unit/array_test.html +28 -0
- data/test/regression/prototype/unit/assets/prototype.js +4900 -0
- data/test/regression/prototype/unit/assets/unittest.css +50 -0
- data/test/regression/prototype/unit/assets/unittest.js +615 -0
- data/test/regression/prototype/unit/assets/unittest_transport.js +1 -0
- data/test/regression/prototype/unit/base_test.html +27 -0
- data/test/regression/prototype/unit/class_test.html +27 -0
- data/test/regression/prototype/unit/date_test.html +27 -0
- data/test/regression/prototype/unit/dom_test.html +304 -0
- data/test/regression/prototype/unit/element_mixins_test.html +30 -0
- data/test/regression/prototype/unit/enumerable_test.html +35 -0
- data/test/regression/prototype/unit/event_test.html +31 -0
- data/test/regression/prototype/unit/fixtures/ajax.html +2 -0
- data/test/regression/prototype/unit/fixtures/ajax.js +42 -0
- data/test/regression/prototype/unit/fixtures/array.html +1 -0
- data/test/regression/prototype/unit/fixtures/class.js +83 -0
- data/test/regression/prototype/unit/fixtures/content.html +1 -0
- data/test/regression/prototype/unit/fixtures/data.json +1 -0
- data/test/regression/prototype/unit/fixtures/dom.css +84 -0
- data/test/regression/prototype/unit/fixtures/dom.html +278 -0
- data/test/regression/prototype/unit/fixtures/dom.js +17 -0
- data/test/regression/prototype/unit/fixtures/element_mixins.html +4 -0
- data/test/regression/prototype/unit/fixtures/element_mixins.js +2 -0
- data/test/regression/prototype/unit/fixtures/empty.html +0 -0
- data/test/regression/prototype/unit/fixtures/empty.js +1 -0
- data/test/regression/prototype/unit/fixtures/enumerable.html +8 -0
- data/test/regression/prototype/unit/fixtures/enumerable.js +23 -0
- data/test/regression/prototype/unit/fixtures/event.html +4 -0
- data/test/regression/prototype/unit/fixtures/form.html +108 -0
- data/test/regression/prototype/unit/fixtures/function.js +13 -0
- data/test/regression/prototype/unit/fixtures/hash.js +25 -0
- data/test/regression/prototype/unit/fixtures/hello.js +1 -0
- data/test/regression/prototype/unit/fixtures/logo.gif +0 -0
- data/test/regression/prototype/unit/fixtures/object.html +6 -0
- data/test/regression/prototype/unit/fixtures/object.js +7 -0
- data/test/regression/prototype/unit/fixtures/position.html +9 -0
- data/test/regression/prototype/unit/fixtures/selector.html +71 -0
- data/test/regression/prototype/unit/fixtures/string.js +8 -0
- data/test/regression/prototype/unit/fixtures/unittest.html +18 -0
- data/test/regression/prototype/unit/form_test.html +135 -0
- data/test/regression/prototype/unit/function_test.html +27 -0
- data/test/regression/prototype/unit/hash_test.html +27 -0
- data/test/regression/prototype/unit/number_test.html +27 -0
- data/test/regression/prototype/unit/object_test.html +32 -0
- data/test/regression/prototype/unit/periodical_executer_test.html +27 -0
- data/test/regression/prototype/unit/position_test.html +36 -0
- data/test/regression/prototype/unit/prototype_test.html +27 -0
- data/test/regression/prototype/unit/range_test.html +27 -0
- data/test/regression/prototype/unit/regexp_test.html +27 -0
- data/test/regression/prototype/unit/selector_test.html +98 -0
- data/test/regression/prototype/unit/string_test.html +27 -0
- data/test/regression/prototype/unit/tests/ajax_test.js +379 -0
- data/test/regression/prototype/unit/tests/array_test.js +186 -0
- data/test/regression/prototype/unit/tests/base_test.js +43 -0
- data/test/regression/prototype/unit/tests/class_test.js +136 -0
- data/test/regression/prototype/unit/tests/date_test.js +5 -0
- data/test/regression/prototype/unit/tests/dom_test.js +1493 -0
- data/test/regression/prototype/unit/tests/element_mixins_test.js +32 -0
- data/test/regression/prototype/unit/tests/enumerable_test.js +271 -0
- data/test/regression/prototype/unit/tests/event_test.js +235 -0
- data/test/regression/prototype/unit/tests/form_test.js +382 -0
- data/test/regression/prototype/unit/tests/function_test.js +133 -0
- data/test/regression/prototype/unit/tests/hash_test.js +178 -0
- data/test/regression/prototype/unit/tests/number_test.js +44 -0
- data/test/regression/prototype/unit/tests/object_test.js +180 -0
- data/test/regression/prototype/unit/tests/periodical_executer_test.js +15 -0
- data/test/regression/prototype/unit/tests/position_test.js +44 -0
- data/test/regression/prototype/unit/tests/prototype_test.js +43 -0
- data/test/regression/prototype/unit/tests/range_test.js +58 -0
- data/test/regression/prototype/unit/tests/regexp_test.js +42 -0
- data/test/regression/prototype/unit/tests/selector_test.js +408 -0
- data/test/regression/prototype/unit/tests/string_test.js +548 -0
- data/test/regression/prototype/unit/tests/unittest_test.js +148 -0
- data/test/regression/prototype/unit/unittest_test.html +45 -0
- data/test/regression/prototype/upstream +1 -0
- data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_ipce_alt_text.html +1 -0
- data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_ipce_collection.js +1 -0
- data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_result.html +1 -0
- data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_result2.html +1 -0
- data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_tagged.html +1 -0
- data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_text.html +1 -0
- data/test/regression/scriptaculous/unit/_ajax_updater_result.html +20 -0
- data/test/regression/scriptaculous/unit/_autocomplete_result.html +11 -0
- data/test/regression/scriptaculous/unit/_autocomplete_result_nobr.html +1 -0
- data/test/regression/scriptaculous/unit/ajax_autocompleter_test.html +243 -0
- data/test/regression/scriptaculous/unit/ajax_inplaceeditor_test.html +895 -0
- data/test/regression/scriptaculous/unit/assets/builder.js +134 -0
- data/test/regression/scriptaculous/unit/assets/controls.js +963 -0
- data/test/regression/scriptaculous/unit/assets/dragdrop.js +973 -0
- data/test/regression/scriptaculous/unit/assets/effects.js +1122 -0
- data/test/regression/scriptaculous/unit/assets/javascripttest.rb +203 -0
- data/test/regression/scriptaculous/unit/assets/prototype.js +4320 -0
- data/test/regression/scriptaculous/unit/assets/scriptaculous.js +66 -0
- data/test/regression/scriptaculous/unit/assets/slider.js +273 -0
- data/test/regression/scriptaculous/unit/assets/sound.js +57 -0
- data/test/regression/scriptaculous/unit/assets/unittest.js +566 -0
- data/test/regression/scriptaculous/unit/bdd_test.html +150 -0
- data/test/regression/scriptaculous/unit/builder_test.html +262 -0
- data/test/regression/scriptaculous/unit/dragdrop_test.html +131 -0
- data/test/regression/scriptaculous/unit/effects_test.html +547 -0
- data/test/regression/scriptaculous/unit/element_test.html +116 -0
- data/test/regression/scriptaculous/unit/icon.png +0 -0
- data/test/regression/scriptaculous/unit/index.html +70 -0
- data/test/regression/scriptaculous/unit/loading_test.html +41 -0
- data/test/regression/scriptaculous/unit/position_clone_test.html +312 -0
- data/test/regression/scriptaculous/unit/slider_test.html +437 -0
- data/test/regression/scriptaculous/unit/sortable_test.html +205 -0
- data/test/regression/scriptaculous/unit/string_test.html +71 -0
- data/test/regression/scriptaculous/unit/unittest_test.html +154 -0
- data/test/regression/scriptaculous/upstream +1 -0
- data/test/test_helper.rb +20 -0
- data/test/unit/runner_test.rb +165 -0
- data/test/unit/test_case_test.rb +207 -0
- data/test/unit/test_test.rb +24 -0
- metadata +209 -0
data/README.rdoc
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
= Headless Squirrel
|
2
|
+
|
3
|
+
A JavaScript test runner to run tests from the comfort of your terminal.
|
4
|
+
|
5
|
+
http://github.com/Fingertips/headless-squirrel/raw/master/html/images/headless-squirrel.png
|
6
|
+
|
7
|
+
== Why?
|
8
|
+
|
9
|
+
Because we want to run tests in a real browser environment, in our case WebKit,
|
10
|
+
but in the same fashion we run out other (Rails) unit tests.
|
11
|
+
|
12
|
+
And we want to write the tests in a way that we can easily run them on other
|
13
|
+
browsers as well, you know, html and js… This way we can run the tests from the
|
14
|
+
terminal during regular development but still test on other browsers by loading
|
15
|
+
the html/js files manually.
|
16
|
+
|
17
|
+
Read more at http://superalloy.nl/2009/04/13/js-test-san.html
|
18
|
+
|
19
|
+
== Install & Usage
|
20
|
+
|
21
|
+
$ sudo gem install Fingertips-headless-squirrel -s http://gems.github.com
|
22
|
+
$ jstest path/to/a/unit_test.html
|
23
|
+
|
24
|
+
To automatically run your test see http://github.com/alloy/kicker/tree/master.
|
25
|
+
|
26
|
+
== Problems?
|
27
|
+
|
28
|
+
You betcha! (See the example.)
|
29
|
+
|
30
|
+
But these shouldn't likely be a typical use case, I hope. So it actually works
|
31
|
+
quite well seeing how many tests pass ;) The one that does fail has to do with
|
32
|
+
the fact that there's no window at all. I haven't yet tried if it will simply
|
33
|
+
work with a NSWindow. Also not sure yet why the end result says 2 failures…
|
34
|
+
|
35
|
+
== Example:
|
36
|
+
|
37
|
+
This is the output of the regression tests which are the Prototype unit tests:
|
38
|
+
|
39
|
+
$ ./bin/jstest test/regression/prototype/unit/*_test.html
|
40
|
+
...................................................................................................................................
|
41
|
+
.......F...........................................................................................................................
|
42
|
+
..............................................................................................
|
43
|
+
|
44
|
+
1) Failed:
|
45
|
+
testViewportDimensions (Unit test file | Dom | default template | 2009-04-11 15:28) [test/regression/prototype/unit/dom_test.html]:
|
46
|
+
Failure: NOTE: YOU MUST ALLOW JAVASCRIPT TO RESIZE YOUR WINDOW FOR THIS TEST TO PASS
|
47
|
+
expected: <50>, actual: <0>
|
48
|
+
Failure: NOTE: YOU MUST ALLOW JAVASCRIPT TO RESIZE YOUR WINDOW FOR THIS TEST TO PASS
|
49
|
+
expected: <50>, actual: <0>
|
50
|
+
|
51
|
+
Finished in 17.725139 seconds.
|
52
|
+
|
53
|
+
356 tests, 2246 assertions, 2 failures, 0 errors
|
54
|
+
|
55
|
+
See regression_test.rdoc[http://github.com/Fingertips/headless-squirrel/blob/master/regression_test.rdoc] for more tests.
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
task :default => :test
|
2
|
+
|
3
|
+
desc "Run the tests"
|
4
|
+
task :test do
|
5
|
+
sh "ruby -r#{Dir['test/unit/*_test.rb'].join(' -r')} -e ''"
|
6
|
+
end
|
7
|
+
|
8
|
+
# HeadlessSquirrel::Rake::Runner.new :regression do |t|
|
9
|
+
# t.files = Dir['test/regression/prototype/unit/*.html']
|
10
|
+
# end
|
11
|
+
|
12
|
+
desc "Run all the regression tests"
|
13
|
+
task :ci do
|
14
|
+
sh "./bin/jstest #{Dir['test/regression/**/unit/*_test.html'].join(' ')}"
|
15
|
+
end
|
16
|
+
|
17
|
+
namespace :ci do
|
18
|
+
desc "Run the prototype regression tests"
|
19
|
+
task :prototype do
|
20
|
+
sh "./bin/jstest #{Dir['test/regression/prototype/unit/*_test.html'].join(' ')}"
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Run the scriptaculous regression tests"
|
24
|
+
task :scriptaculous do
|
25
|
+
sh "./bin/jstest #{Dir['test/regression/scriptaculous/unit/*_test.html'].join(' ')}"
|
26
|
+
end
|
27
|
+
end
|
data/bin/jstest
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# TODO: Needs converage.
|
2
|
+
module HeadlessSquirrel
|
3
|
+
class Console < OSX::NSObject
|
4
|
+
objc_class_method 'isSelectorExcludedFromWebScript:', [:BOOL, :sel]
|
5
|
+
def self.isSelectorExcludedFromWebScript(selector)
|
6
|
+
selector != 'log:'
|
7
|
+
end
|
8
|
+
|
9
|
+
objc_class_method 'webScriptNameForSelector:', [:id, :sel]
|
10
|
+
def self.webScriptNameForSelector(selector)
|
11
|
+
'log' if selector == 'log:'
|
12
|
+
end
|
13
|
+
|
14
|
+
objc_method 'log:', [:void, :id]
|
15
|
+
def log(object)
|
16
|
+
puts object.description
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# For some reason RC looks for the Console class in the OSX namespace.
|
22
|
+
before, $VERBOSE = $VERBOSE, nil
|
23
|
+
OSX::Console = HeadlessSquirrel::Console
|
24
|
+
$VERBOSE = before
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'osx/cocoa'
|
2
|
+
|
3
|
+
module HeadlessSquirrel
|
4
|
+
class Runner < OSX::NSObject
|
5
|
+
attr_reader :test_cases, :queued, :did_not_pass
|
6
|
+
|
7
|
+
def initWithHTMLFiles(html_files)
|
8
|
+
if init
|
9
|
+
@test_cases = []
|
10
|
+
@test_cases = html_files.map { |file| TestCase.alloc.initWithHTMLFile_delegate(file, self) }
|
11
|
+
@queued = @test_cases.dup
|
12
|
+
@did_not_pass = []
|
13
|
+
|
14
|
+
$stdout.sync = true
|
15
|
+
|
16
|
+
self
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
@start_time = Time.now
|
22
|
+
@queued.first.run
|
23
|
+
OSX::NSApplication.sharedApplication.run
|
24
|
+
end
|
25
|
+
|
26
|
+
def tests; sum :tests end
|
27
|
+
def assertions; sum :assertions end
|
28
|
+
def failures; sum :failures end
|
29
|
+
def errors; sum :errors end
|
30
|
+
|
31
|
+
def test_ran(test)
|
32
|
+
@did_not_pass << test unless test.state == :passed
|
33
|
+
|
34
|
+
print case test.state
|
35
|
+
when :passed
|
36
|
+
'.'
|
37
|
+
when :failed
|
38
|
+
'F'
|
39
|
+
when :error
|
40
|
+
'E'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_case_finished(test_case)
|
45
|
+
@queued.delete(test_case)
|
46
|
+
@queued.empty? ? finalize : @queued.first.run
|
47
|
+
end
|
48
|
+
|
49
|
+
def finished?
|
50
|
+
@finished
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def sum(attr)
|
56
|
+
@test_cases.inject(0) { |sum, tc| sum += tc.send(attr) }
|
57
|
+
end
|
58
|
+
|
59
|
+
def finalize
|
60
|
+
@finished = true
|
61
|
+
|
62
|
+
puts
|
63
|
+
@did_not_pass.each_with_index { |test, index| puts "\n #{index+1}) #{test}" }
|
64
|
+
puts "Finished in #{Time.now - @start_time} seconds."
|
65
|
+
puts "\n#{tests} tests, #{assertions} assertions, #{failures} failures, #{errors} errors"
|
66
|
+
|
67
|
+
OSX::NSApplication.sharedApplication.terminate(self)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module HeadlessSquirrel
|
2
|
+
class TestCase < OSX::NSObject
|
3
|
+
class Test
|
4
|
+
attr_reader :test_case, :name, :state, :output
|
5
|
+
|
6
|
+
def initialize(test_case, name, state, output)
|
7
|
+
@test_case, @name, @state, @output = test_case, name, state, output
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_s
|
11
|
+
%{#{@state.to_s.capitalize}:
|
12
|
+
#{@name} (#{@test_case.title}) [#{@test_case.html_file}]:
|
13
|
+
#{@output}}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
require "osx/cocoa"
|
2
|
+
OSX.require_framework 'WebKit'
|
3
|
+
|
4
|
+
require 'headless_squirrel/test'
|
5
|
+
require 'headless_squirrel/console'
|
6
|
+
|
7
|
+
module HeadlessSquirrel
|
8
|
+
class TestCase < OSX::NSObject
|
9
|
+
class FileDoesNotExistError < StandardError; end
|
10
|
+
|
11
|
+
def self.sharedWebView
|
12
|
+
@sharedWebView ||= OSX::WebView.alloc.init
|
13
|
+
end
|
14
|
+
|
15
|
+
RESULTS_REGEXP_KEYS = [:report, :_, :tests, :assertions, :failures, :errors]
|
16
|
+
RESULTS_REGEXP = /((\d+) tests, )?(\d+) assertions, (\d+) failures, (\d+) errors\n?/
|
17
|
+
|
18
|
+
STATES = %w{ passed failed error }
|
19
|
+
|
20
|
+
attr_reader :html_file, :delegate, :title
|
21
|
+
attr_reader :tests, :assertions, :failures, :errors
|
22
|
+
|
23
|
+
def initWithHTMLFile_delegate(html_file, delegate)
|
24
|
+
if init
|
25
|
+
raise FileDoesNotExistError, "The file `#{html_file}' does not exist." unless File.exist?(html_file)
|
26
|
+
@html_file, @delegate = html_file, delegate
|
27
|
+
@tests = @assertions = @failures = @errors = 0
|
28
|
+
@title = ''
|
29
|
+
self
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def run
|
34
|
+
webView
|
35
|
+
end
|
36
|
+
|
37
|
+
def finished?
|
38
|
+
@finished
|
39
|
+
end
|
40
|
+
|
41
|
+
def webView
|
42
|
+
@webView ||= load_webView
|
43
|
+
end
|
44
|
+
|
45
|
+
def document
|
46
|
+
webView.mainFrame.DOMDocument
|
47
|
+
end
|
48
|
+
|
49
|
+
def log
|
50
|
+
document.getElementsByClassName('logsummary').item(0) || document.getElementById('logsummary')
|
51
|
+
end
|
52
|
+
|
53
|
+
def loglines
|
54
|
+
document.getElementsByClassName('loglines').item(0) || document.getElementById('loglines')
|
55
|
+
end
|
56
|
+
|
57
|
+
# Not yet sure why the extra check for log not being nil is necessary.
|
58
|
+
# Might be a test only thing.
|
59
|
+
def webView_didFinishLoadForFrame(_, __)
|
60
|
+
@title = webView.mainFrameTitle.to_s
|
61
|
+
[log, loglines].each do |element|
|
62
|
+
element.addEventListener___('DOMSubtreeModified', self, true) if element
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def webView_didClearWindowObject_forFrame(_, scriptObject, __)
|
67
|
+
scriptObject.setValue_forKey(HeadlessSquirrel::Console.alloc.init, 'console')
|
68
|
+
end
|
69
|
+
|
70
|
+
# Catches resource load errors:
|
71
|
+
#
|
72
|
+
# webView.resourceLoadDelegate = self
|
73
|
+
#
|
74
|
+
# def webView_resource_didFailLoadingWithError_fromDataSource(w,r,e,d)
|
75
|
+
# message = "#{e.userInfo['NSLocalizedDescription']}: #{e.userInfo['NSErrorFailingURLStringKey']}"
|
76
|
+
# @delegate.test_ran(Test.new(self, "Unable to load test case", :failed, message))
|
77
|
+
# @delegate.test_case_finished(self)
|
78
|
+
# end
|
79
|
+
|
80
|
+
def webView_addMessageToConsole(_, info)
|
81
|
+
puts format_js_log(info)
|
82
|
+
OSX::NSApplication.sharedApplication.terminate(self) if info['message'].to_s =~ /^[A-Z]\w+Error/
|
83
|
+
end
|
84
|
+
|
85
|
+
def handleEvent(event)
|
86
|
+
element = event.target
|
87
|
+
|
88
|
+
case element
|
89
|
+
when OSX::DOMText
|
90
|
+
contents = element.wholeText.to_s
|
91
|
+
when OSX::DOMHTMLTableCellElement, OSX::DOMHTMLDivElement
|
92
|
+
contents = element.innerText.to_s
|
93
|
+
end
|
94
|
+
|
95
|
+
if contents
|
96
|
+
if result = self.class.parse_result(contents)
|
97
|
+
if result[:tests]
|
98
|
+
finalize_test_suite(result)
|
99
|
+
else
|
100
|
+
finalize_test(result)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
def load_webView
|
109
|
+
url = OSX::NSURL.fileURLWithPath(@html_file)
|
110
|
+
req = OSX::NSURLRequest.requestWithURL(url)
|
111
|
+
webView = self.class.sharedWebView
|
112
|
+
webView.mainFrame.loadRequest(req)
|
113
|
+
webView.frameLoadDelegate = self
|
114
|
+
webView.setUIDelegate(self)
|
115
|
+
webView
|
116
|
+
end
|
117
|
+
|
118
|
+
def format_js_log(info)
|
119
|
+
"#{info['sourceURL'][7..-1]}:#{info['lineNumber']}: #{info['message']}"
|
120
|
+
end
|
121
|
+
|
122
|
+
def finalize_test(result)
|
123
|
+
last_line = loglines.children.item(loglines.children.length-1)
|
124
|
+
log_row = self.class.parse_log_row(last_line)
|
125
|
+
|
126
|
+
@delegate.test_ran(Test.new(self, log_row[:name], log_row[:state].to_sym, result[:message]))
|
127
|
+
end
|
128
|
+
|
129
|
+
def finalize_test_suite(result)
|
130
|
+
@finished = true
|
131
|
+
@tests, @assertions, @failures, @errors = result[:tests].to_i, result[:assertions].to_i, result[:failures].to_i, result[:errors].to_i
|
132
|
+
@delegate.test_case_finished(self)
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.parse_result(line)
|
136
|
+
if match = RESULTS_REGEXP.match(line)
|
137
|
+
result = Hash[*RESULTS_REGEXP_KEYS.zip(match.to_a).flatten]
|
138
|
+
result[:message] = line.sub(result[:report], '')
|
139
|
+
result
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def self.parse_log_row(row)
|
144
|
+
parts = []
|
145
|
+
0.upto(row.children.length-1) do |i|
|
146
|
+
parts << row.children.item(i).innerText.to_s.strip
|
147
|
+
end
|
148
|
+
|
149
|
+
# Recent version of unittest.js
|
150
|
+
if STATES.include?(parts.first)
|
151
|
+
{ :state => parts[0], :name => parts[1] }
|
152
|
+
# Older version
|
153
|
+
else
|
154
|
+
{ :state => parts[1], :name => parts[0] }
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<title>A HeadlessSquirrel Unit Test HTML File</title>
|
6
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
7
|
+
|
8
|
+
<script type="text/javascript" charset="utf-8">
|
9
|
+
var eventResults = {};
|
10
|
+
var originalElement = window.Element;
|
11
|
+
</script>
|
12
|
+
|
13
|
+
<script src="../regression/prototype/unit/assets/prototype.js" type="text/javascript" charset="utf-8"></script>
|
14
|
+
<script src="../regression/prototype/unit/assets/unittest.js" type="text/javascript" charset="utf-8"></script>
|
15
|
+
<script src="a_unit_test.js" type="text/javascript" charset="utf-8"></script>
|
16
|
+
</head>
|
17
|
+
<body>
|
18
|
+
|
19
|
+
<div id="testlog"></div>
|
20
|
+
|
21
|
+
<div id="content"></div>
|
22
|
+
|
23
|
+
</body>
|
24
|
+
</html>
|
25
|
+
<script type="text/javascript" charset="utf-8">
|
26
|
+
eventResults.endOfDocument = true;
|
27
|
+
</script>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
// 3 tests, 2 assertions, 1 failures, 1 errors
|
2
|
+
|
3
|
+
new Test.Unit.Runner({
|
4
|
+
setup: function() {
|
5
|
+
this.content = $('content');
|
6
|
+
this.content.update('');
|
7
|
+
},
|
8
|
+
|
9
|
+
testHelloWorldSuccess: function() {
|
10
|
+
this.assertEqual("", this.content.innerHTML);
|
11
|
+
this.content.update('Hello world!');
|
12
|
+
this.assertEqual("Hello world!", this.content.innerHTML);
|
13
|
+
},
|
14
|
+
|
15
|
+
testHelloWorldFailure: function() {
|
16
|
+
this.assertEqual("Hello world!", this.content.innerHTML);
|
17
|
+
},
|
18
|
+
|
19
|
+
testHelloWorldError: function() {
|
20
|
+
this.content.foo();
|
21
|
+
},
|
22
|
+
});
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<title>A HeadlessSquirrel Unit Test HTML File With Syntax Error</title>
|
6
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
7
|
+
|
8
|
+
<script type="text/javascript" charset="utf-8">
|
9
|
+
var eventResults = {};
|
10
|
+
var originalElement = window.Element;
|
11
|
+
</script>
|
12
|
+
|
13
|
+
<script src="../regression/prototype/unit/assets/prototype.js" type="text/javascript" charset="utf-8"></script>
|
14
|
+
<script src="../regression/prototype/unit/assets/unittest.js" type="text/javascript" charset="utf-8"></script>
|
15
|
+
<script src="syntax_error.js" type="text/javascript" charset="utf-8"></script>
|
16
|
+
</head>
|
17
|
+
<body>
|
18
|
+
|
19
|
+
<div id="testlog"></div>
|
20
|
+
|
21
|
+
<div id="content"></div>
|
22
|
+
|
23
|
+
</body>
|
24
|
+
</html>
|
25
|
+
<script type="text/javascript" charset="utf-8">
|
26
|
+
eventResults.endOfDocument = true;
|
27
|
+
</script>
|