/
auto_runner.js
53 lines (44 loc) · 1.49 KB
/
auto_runner.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
JS.Test.Unit.extend({
/** section: test
* class JS.Test.Unit.AutoRunner
**/
AutoRunner: new JS.Class({
extend: {
/**
* JS.Test.Unit.AutoRunner.run() -> JS.Test.Unit.TestResult
**/
run: function(outputLevel) {
var runner = this.getRunner(),
names = [],
suites = [];
JS.Test.Unit.TestCase.resolve();
JS.Test.Unit.TestCase.forEach(function(testcase) {
suites.push(testcase.suite());
if (testcase.superclass === JS.Test.Unit.TestCase)
names.push(testcase.displayName);
});
var suite = new JS.Test.Unit.TestSuite(names.join(', '));
for (var i = 0, n = suites.length; i < n; i++)
suite.push(suites[i]);
JS.Test.Unit.TestCase.clear();
return runner.run(suite, this.OUTPUT_LEVELS[outputLevel || 'normal']);
},
getRunner: function() {
return (typeof window !== 'undefined')
? this.RUNNERS.browser
: this.RUNNERS.console;
},
RUNNERS: {
console: JS.Test.Unit.UI.Console.TestRunner,
browser: JS.Test.Unit.UI.Browser.TestRunner
},
OUTPUT_LEVELS: {
silent: JS.Test.Unit.UI.SILENT,
progress: JS.Test.Unit.UI.PROGRESS_ONLY,
normal: JS.Test.Unit.UI.NORMAL,
verbose: JS.Test.Unit.UI.VERBOSE
}
}
})
});
JS.Test.extend({ autorun: JS.Test.Unit.AutoRunner.method('run') });