asproject 0.1.92 → 0.1.118
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/lib/asclass_arguments.rb +1 -1
- data/lib/asproject.rb +3 -1
- data/lib/asproject/version.rb +1 -1
- data/lib/asproject_arguments.rb +5 -5
- data/lib/path_finder.rb +17 -7
- data/lib/tasks/asunit.rb +8 -0
- data/lib/tasks/flash_log.rb +2 -1
- data/lib/tasks/flash_player.rb +10 -6
- data/lib/tasks/mxmlc.rb +13 -2
- data/lib/tasks/remote_file_loader.rb +144 -0
- data/lib/tasks/remote_file_task.rb +2 -128
- data/lib/tasks/remote_library_task.rb +75 -0
- data/templates/asclass/as2/Class.as +1 -1
- data/templates/asproject/as2/{art → assets}/.crap_file +0 -0
- data/templates/asproject/as2/project/rakefile.rb +3 -2
- data/templates/asproject/as3/{art → assets}/.crap_file +0 -0
- data/templates/asproject/as3/project/rakefile.rb +3 -3
- data/templates/asproject/fdt/project/.as2_classpath +1 -1
- metadata +9 -129
- data/templates/asproject/asunit2/project/lib/asunit/AsUnitUi.swf +0 -0
- data/templates/asproject/asunit2/project/lib/asunit/Sys.as +0 -70
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanel.as +0 -182
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTest.as +0 -84
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTextArea.as +0 -111
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTextAreaTest.as +0 -26
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTitleBar.as +0 -81
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ResizeHandle.as +0 -35
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollArrow.as +0 -34
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollHandle.as +0 -43
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollListener.as +0 -10
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/TextScroller.as +0 -169
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/shapes/Rectangle.as +0 -29
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/shapes/Triangle.as +0 -27
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/AsUnit.as +0 -19
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Assert.as +0 -408
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Assertion.as +0 -27
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as +0 -68
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Test.as +0 -3
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestCase.as +0 -191
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestCaseXml.as +0 -31
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestFailure.as +0 -15
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestResult.as +0 -15
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestRunner.as +0 -41
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestSetup.as +0 -19
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestSuite.as +0 -22
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/Main.as +0 -325
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/RemoteVersion.as +0 -24
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/SuccessMeter.as +0 -32
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/Comparable.as +0 -7
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/EventListener.as +0 -29
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/EventSource.as +0 -89
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnClient.as +0 -42
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnGateway.as +0 -47
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnServer.as +0 -61
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalMessageBroker.as +0 -58
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/Observable.as +0 -11
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/TextFile.as +0 -30
- data/templates/asproject/asunit25/project/lib/asunit/AsUnitTestRunner.as +0 -13
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/AssertionFailedError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/AssertionPassedError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/ClassNotFoundError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/IllegalOperationError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/InstanceNotFoundError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/InvocationTargetError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/UnimplementedFeatureError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/Assert.as +0 -376
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/AssertMock.as +0 -15
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/AssertTest.as +0 -59
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/ITestListener.as +0 -13
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/Test.as +0 -11
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCase.as +0 -278
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseMock.as +0 -23
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseTest.as +0 -29
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseXml.as +0 -38
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestFailure.as +0 -47
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestResult.as +0 -168
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestSuite.as +0 -102
- data/templates/asproject/asunit25/project/lib/asunit/asunit/runner/BaseTestRunner.as +0 -101
- data/templates/asproject/asunit25/project/lib/asunit/asunit/runner/IResultPrinter.as +0 -8
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/ResultPrinter.as +0 -254
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/SuccessBar.as +0 -41
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/TestRunner.as +0 -17
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/ArrayIterator.as +0 -24
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/ArrayIteratorTest.as +0 -52
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/Iterator.as +0 -5
- data/templates/asproject/asunit3/project/lib/asunit/AsUnitTestRunner.as +0 -10
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/AbstractMemberCalledError.as +0 -10
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/AssertionFailedError.as +0 -10
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/ClassNotFoundError.as +0 -10
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/InstanceNotFoundError.as +0 -10
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/UnimplementedFeatureError.as +0 -10
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/Assert.as +0 -271
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCase.as +0 -52
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCaseExample.as +0 -71
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/Test.as +0 -15
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestCase.as +0 -354
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestCaseExample.as +0 -73
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestFailure.as +0 -47
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestListener.as +0 -22
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestResult.as +0 -158
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestSuite.as +0 -115
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/BaseTestRunner.as +0 -15
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/TestSuiteLoader.as +0 -9
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/Version.as +0 -11
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/FlexRunner.as +0 -19
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/FlexTestRunner.as +0 -55
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/ResultPrinter.as +0 -245
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/TestRunner.as +0 -121
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/ArrayIterator.as +0 -26
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/Iterator.as +0 -9
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/Properties.as +0 -30
@@ -1,73 +0,0 @@
|
|
1
|
-
package asunit.framework {
|
2
|
-
import asunit.framework.TestCase;
|
3
|
-
import flash.display.Sprite;
|
4
|
-
import flash.events.Event;
|
5
|
-
import flash.events.IEventDispatcher;
|
6
|
-
import flash.events.EventDispatcher;
|
7
|
-
import flash.utils.setTimeout;
|
8
|
-
|
9
|
-
// TestCase subclasses should always end with 'Test', the example
|
10
|
-
// doesn't because we don't want TestSuites in this directory.
|
11
|
-
public class TestCaseExample extends TestCase {
|
12
|
-
private var date:Date;
|
13
|
-
private var sprite:Sprite;
|
14
|
-
|
15
|
-
// TestCase constructors must be implemented as follows
|
16
|
-
// so that we can execute a single method on them from
|
17
|
-
// the TestRunner
|
18
|
-
public function TestCaseExample(testMethod:String = null) {
|
19
|
-
super(testMethod);
|
20
|
-
}
|
21
|
-
|
22
|
-
// This method will be called before every test method
|
23
|
-
override protected function setUp():void {
|
24
|
-
date = new Date();
|
25
|
-
// sprite = new Sprite();
|
26
|
-
// addChild(sprite);
|
27
|
-
}
|
28
|
-
|
29
|
-
// This method will be called after every test method
|
30
|
-
// but only if we're executing the entire TestCase,
|
31
|
-
// the tearDown method won't be called if we're
|
32
|
-
// calling start(MyTestCase, "someMethod");
|
33
|
-
override protected function tearDown():void {
|
34
|
-
// removeChild(sprite);
|
35
|
-
// sprite = null;
|
36
|
-
date = null;
|
37
|
-
}
|
38
|
-
|
39
|
-
// This is auto-created by the XULUI and ensures that
|
40
|
-
// our objects are actually created as we expect.
|
41
|
-
public function testInstantiated():void {
|
42
|
-
assertTrue("Date instantiated", date is Date);
|
43
|
-
// assertTrue("Sprite instantiated", sprite is Sprite);
|
44
|
-
}
|
45
|
-
|
46
|
-
// This is an example of a typical test method
|
47
|
-
public function testMonthGetterSetter():void {
|
48
|
-
date.month = 1;
|
49
|
-
assertEquals(1, date.month);
|
50
|
-
}
|
51
|
-
|
52
|
-
// This is an asynchronous test method
|
53
|
-
public function testAsyncFeature():void {
|
54
|
-
// create a new object that dispatches events...
|
55
|
-
var dispatcher:IEventDispatcher = new EventDispatcher();
|
56
|
-
// get a TestCase async event handler reference
|
57
|
-
// the 2nd arg is an optional timeout in ms. (default=1000ms )
|
58
|
-
var handler:Function = addAsync(changeHandler, 2000);
|
59
|
-
// subscribe to your event dispatcher using the returned handler
|
60
|
-
dispatcher.addEventListener(Event.CHANGE, handler);
|
61
|
-
// cause the event to be dispatched.
|
62
|
-
// either immediately:
|
63
|
-
//dispatcher.dispatchEvent(new Event(Event.CHANGE));
|
64
|
-
// or in the future < your assigned timeout
|
65
|
-
setTimeout( dispatcher.dispatchEvent, 200, new Event(Event.CHANGE));
|
66
|
-
}
|
67
|
-
|
68
|
-
protected function changeHandler(event:Event):void {
|
69
|
-
// perform assertions in your handler
|
70
|
-
assertEquals(Event.CHANGE, event.type);
|
71
|
-
}
|
72
|
-
}
|
73
|
-
}
|
@@ -1,47 +0,0 @@
|
|
1
|
-
package asunit.framework {
|
2
|
-
import asunit.errors.AssertionFailedError;
|
3
|
-
|
4
|
-
/**
|
5
|
-
* A <code>TestFailure</code> collects a failed test together with
|
6
|
-
* the caught exception.
|
7
|
-
* @see TestResult
|
8
|
-
*/
|
9
|
-
public class TestFailure {
|
10
|
-
protected var fFailedTest:String;
|
11
|
-
protected var fThrownException:Error;
|
12
|
-
|
13
|
-
/**
|
14
|
-
* Constructs a TestFailure with the given test and exception.
|
15
|
-
*/
|
16
|
-
public function TestFailure(failedTest:Test, thrownException:Error) {
|
17
|
-
fFailedTest = failedTest.toString();
|
18
|
-
fThrownException = thrownException;
|
19
|
-
}
|
20
|
-
/**
|
21
|
-
* Gets the failed test.
|
22
|
-
*/
|
23
|
-
public function failedTest():String {
|
24
|
-
return fFailedTest;
|
25
|
-
}
|
26
|
-
/**
|
27
|
-
* Gets the thrown exception.
|
28
|
-
*/
|
29
|
-
public function thrownException():Error {
|
30
|
-
return fThrownException;
|
31
|
-
}
|
32
|
-
/**
|
33
|
-
* Returns a short description of the failure.
|
34
|
-
*/
|
35
|
-
public function toString():String {
|
36
|
-
return "";
|
37
|
-
}
|
38
|
-
|
39
|
-
public function exceptionMessage():String {
|
40
|
-
return thrownException().message;
|
41
|
-
}
|
42
|
-
|
43
|
-
public function isFailure():Boolean {
|
44
|
-
return thrownException() is AssertionFailedError;
|
45
|
-
}
|
46
|
-
}
|
47
|
-
}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
package asunit.framework {
|
2
|
-
import asunit.errors.AssertionFailedError;
|
3
|
-
|
4
|
-
public interface TestListener {
|
5
|
-
/**
|
6
|
-
* An error occurred.
|
7
|
-
*/
|
8
|
-
function addError(test:Test, t:Error):void;
|
9
|
-
/**
|
10
|
-
* A failure occurred.
|
11
|
-
*/
|
12
|
-
function addFailure(test:Test, t:AssertionFailedError):void;
|
13
|
-
/**
|
14
|
-
* A test ended.
|
15
|
-
*/
|
16
|
-
function endTest(test:Test):void;
|
17
|
-
/**
|
18
|
-
* A test started.
|
19
|
-
*/
|
20
|
-
function startTest(test:Test):void;
|
21
|
-
}
|
22
|
-
}
|
@@ -1,158 +0,0 @@
|
|
1
|
-
package asunit.framework {
|
2
|
-
import asunit.errors.AssertionFailedError;
|
3
|
-
import asunit.errors.InstanceNotFoundError;
|
4
|
-
|
5
|
-
import flash.errors.IllegalOperationError;
|
6
|
-
import flash.events.EventDispatcher;
|
7
|
-
|
8
|
-
/**
|
9
|
-
* A <code>TestResult</code> collects the results of executing
|
10
|
-
* a test case. It is an instance of the Collecting Parameter pattern.
|
11
|
-
* The test framework distinguishes between <i>failures</i> and <i>errors</i>.
|
12
|
-
* A failure is anticipated and checked for with assertions. Errors are
|
13
|
-
* unanticipated problems like an <code>ArrayIndexOutOfBoundsException</code>.
|
14
|
-
*
|
15
|
-
* @see Test
|
16
|
-
*/
|
17
|
-
public class TestResult {
|
18
|
-
protected var fFailures:Array;
|
19
|
-
protected var fErrors:Array;
|
20
|
-
protected var fListeners:Array;
|
21
|
-
protected var fRunTests:int;
|
22
|
-
private var fStop:Boolean;
|
23
|
-
|
24
|
-
public function TestResult() {
|
25
|
-
fFailures = new Array();
|
26
|
-
fErrors = new Array();
|
27
|
-
fListeners = new Array();
|
28
|
-
fRunTests = 0;
|
29
|
-
fStop = false;
|
30
|
-
}
|
31
|
-
/**
|
32
|
-
* Adds an error to the list of errors. The passed in exception
|
33
|
-
* caused the error.
|
34
|
-
*/
|
35
|
-
public function addError(test:Test, t:Error):void {
|
36
|
-
fErrors.push(new TestFailure(test, t));
|
37
|
-
var len:uint = fListeners.length;
|
38
|
-
var item:TestListener;
|
39
|
-
for(var i:uint; i < len; i++) {
|
40
|
-
item = TestListener(fListeners[i]);
|
41
|
-
item.addError(test, t);
|
42
|
-
}
|
43
|
-
}
|
44
|
-
/**
|
45
|
-
* Adds a failure to the list of failures. The passed in exception
|
46
|
-
* caused the failure.
|
47
|
-
*/
|
48
|
-
public function addFailure(test:Test, t:AssertionFailedError):void {
|
49
|
-
fFailures.push(new TestFailure(test, t));
|
50
|
-
var len:uint = fListeners.length;
|
51
|
-
var item:TestListener;
|
52
|
-
for(var i:uint; i < len; i++) {
|
53
|
-
item = TestListener(fListeners[i]);
|
54
|
-
item.addFailure(test, t);
|
55
|
-
}
|
56
|
-
}
|
57
|
-
/**
|
58
|
-
* Registers a TestListener
|
59
|
-
*/
|
60
|
-
public function addListener(listener:TestListener):void {
|
61
|
-
fListeners.push(listener);
|
62
|
-
}
|
63
|
-
/**
|
64
|
-
* Unregisters a TestListener
|
65
|
-
*/
|
66
|
-
public function removeListener(listener:TestListener):void {
|
67
|
-
var len:uint = fListeners.length;
|
68
|
-
for(var i:uint; i < len; i++) {
|
69
|
-
if(fListeners[i] == listener) {
|
70
|
-
fListeners.splice(i, 1);
|
71
|
-
return;
|
72
|
-
}
|
73
|
-
}
|
74
|
-
throw new InstanceNotFoundError("removeListener called without listener in list");
|
75
|
-
}
|
76
|
-
/**
|
77
|
-
* Gets the number of detected errors.
|
78
|
-
*/
|
79
|
-
public function errorCount():int {
|
80
|
-
return fErrors.length;
|
81
|
-
}
|
82
|
-
/**
|
83
|
-
* Returns an Enumeration for the errors
|
84
|
-
*/
|
85
|
-
public function errors():Array {
|
86
|
-
return fErrors;
|
87
|
-
}
|
88
|
-
/**
|
89
|
-
* Gets the number of detected failures.
|
90
|
-
*/
|
91
|
-
public function failureCount():int {
|
92
|
-
return fFailures.length;
|
93
|
-
}
|
94
|
-
/**
|
95
|
-
* Returns an Enumeration for the failures
|
96
|
-
*/
|
97
|
-
public function failures():Array {
|
98
|
-
return fFailures;
|
99
|
-
}
|
100
|
-
|
101
|
-
/**
|
102
|
-
* Runs a TestCase.
|
103
|
-
*/
|
104
|
-
public function run(test:TestCase):void {
|
105
|
-
startTest(test);
|
106
|
-
test.runBare();
|
107
|
-
}
|
108
|
-
/**
|
109
|
-
* Gets the number of run tests.
|
110
|
-
*/
|
111
|
-
public function runCount():int {
|
112
|
-
return fRunTests;
|
113
|
-
}
|
114
|
-
/**
|
115
|
-
* Checks whether the test run should stop
|
116
|
-
*/
|
117
|
-
public function shouldStop():Boolean {
|
118
|
-
return fStop;
|
119
|
-
}
|
120
|
-
/**
|
121
|
-
* Informs the result that a test will be started.
|
122
|
-
*/
|
123
|
-
public function startTest(test:Test):void {
|
124
|
-
var count:int = test.countTestCases();
|
125
|
-
fRunTests += count;
|
126
|
-
|
127
|
-
var len:uint = fListeners.length;
|
128
|
-
var item:TestListener;
|
129
|
-
for(var i:uint; i < len; i++) {
|
130
|
-
item = TestListener(fListeners[i]);
|
131
|
-
item.startTest(test);
|
132
|
-
}
|
133
|
-
}
|
134
|
-
/**
|
135
|
-
* Informs the result that a test was completed.
|
136
|
-
*/
|
137
|
-
public function endTest(test:Test):void {
|
138
|
-
var len:uint = fListeners.length;
|
139
|
-
var item:TestListener;
|
140
|
-
for(var i:uint; i < len; i++) {
|
141
|
-
item = TestListener(fListeners[i]);
|
142
|
-
item.endTest(test);
|
143
|
-
}
|
144
|
-
}
|
145
|
-
/**
|
146
|
-
* Marks that the test run should stop.
|
147
|
-
*/
|
148
|
-
public function stop():void {
|
149
|
-
fStop = true;
|
150
|
-
}
|
151
|
-
/**
|
152
|
-
* Returns whether the entire test was successful or not.
|
153
|
-
*/
|
154
|
-
public function wasSuccessful():Boolean {
|
155
|
-
return failureCount() == 0 && errorCount() == 0;
|
156
|
-
}
|
157
|
-
}
|
158
|
-
}
|
@@ -1,115 +0,0 @@
|
|
1
|
-
package asunit.framework {
|
2
|
-
import flash.display.DisplayObjectContainer;
|
3
|
-
import flash.events.Event;
|
4
|
-
import asunit.util.Iterator;
|
5
|
-
import asunit.util.ArrayIterator;
|
6
|
-
|
7
|
-
/**
|
8
|
-
* A <code>TestSuite</code> is a <code>Composite</code> of Tests.
|
9
|
-
* It runs a collection of test cases. Here is an example using
|
10
|
-
* the dynamic test definition.
|
11
|
-
* <pre>
|
12
|
-
* TestSuite suite = new TestSuite();
|
13
|
-
* suite.addTest(new MathTest());
|
14
|
-
* suite.addTest(new OtherTest());
|
15
|
-
* </pre>
|
16
|
-
* @see Test
|
17
|
-
* @see TestCase
|
18
|
-
*/
|
19
|
-
public class TestSuite extends TestCase implements Test {
|
20
|
-
private var fTests:Array = new Array();
|
21
|
-
private var testsCompleteCount:Number = 0;
|
22
|
-
private var iterator:ArrayIterator;
|
23
|
-
private var isRunning:Boolean;
|
24
|
-
|
25
|
-
public function TestSuite() {
|
26
|
-
super();
|
27
|
-
fTests = new Array();
|
28
|
-
}
|
29
|
-
|
30
|
-
protected override function setTestMethods(methodNodes:XMLList):void {
|
31
|
-
testMethods = new Array();
|
32
|
-
}
|
33
|
-
|
34
|
-
/**
|
35
|
-
* Adds a test to the suite.
|
36
|
-
*/
|
37
|
-
public function addTest(test:Test):void {
|
38
|
-
fTests.push(test);
|
39
|
-
}
|
40
|
-
|
41
|
-
/**
|
42
|
-
* Counts the number of tests that will be run by this Suite.
|
43
|
-
*/
|
44
|
-
public override function countTestCases():int {
|
45
|
-
var count:int;
|
46
|
-
for each(var test:TestCase in fTests) {
|
47
|
-
count = count + test.countTestCases();
|
48
|
-
}
|
49
|
-
return count;
|
50
|
-
}
|
51
|
-
|
52
|
-
/**
|
53
|
-
* Runs the tests and collects their result in a TestResult.
|
54
|
-
*/
|
55
|
-
public override function run():void {
|
56
|
-
var result:TestResult = getResult();
|
57
|
-
var test:Test;
|
58
|
-
var itr:Iterator = getIterator();
|
59
|
-
while(itr.hasNext()) {
|
60
|
-
isRunning = true;
|
61
|
-
test = Test(itr.next());
|
62
|
-
test.setResult(result);
|
63
|
-
test.addEventListener(Event.COMPLETE, testCompleteHandler);
|
64
|
-
test.run();
|
65
|
-
if(!test.getIsComplete()) {
|
66
|
-
isRunning = false;
|
67
|
-
break;
|
68
|
-
}
|
69
|
-
}
|
70
|
-
}
|
71
|
-
|
72
|
-
private function getIterator():ArrayIterator {
|
73
|
-
if(iterator == null) {
|
74
|
-
iterator = new ArrayIterator(fTests);
|
75
|
-
}
|
76
|
-
return iterator;
|
77
|
-
}
|
78
|
-
|
79
|
-
private function testCompleteHandler(event:Event):void {
|
80
|
-
if(!isRunning) {
|
81
|
-
run();
|
82
|
-
}
|
83
|
-
if(++testsCompleteCount >= testCount()) {
|
84
|
-
dispatchEvent(new Event(Event.COMPLETE));
|
85
|
-
}
|
86
|
-
}
|
87
|
-
|
88
|
-
/**
|
89
|
-
* Returns the number of tests in this suite
|
90
|
-
*/
|
91
|
-
public function testCount():int {
|
92
|
-
return fTests.length;
|
93
|
-
}
|
94
|
-
|
95
|
-
public override function toString():String {
|
96
|
-
return getName();
|
97
|
-
}
|
98
|
-
|
99
|
-
public override function getIsComplete():Boolean {
|
100
|
-
for each(var test:TestCase in fTests) {
|
101
|
-
if(!test.getIsComplete()) {
|
102
|
-
return false;
|
103
|
-
}
|
104
|
-
}
|
105
|
-
return true;
|
106
|
-
}
|
107
|
-
|
108
|
-
public override function setContext(context:DisplayObjectContainer):void {
|
109
|
-
super.setContext(context);
|
110
|
-
for each(var test:Test in fTests) {
|
111
|
-
test.setContext(context);
|
112
|
-
}
|
113
|
-
}
|
114
|
-
}
|
115
|
-
}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
package asunit.runner {
|
2
|
-
import flash.display.Sprite;
|
3
|
-
|
4
|
-
/**
|
5
|
-
* Base class for all test runners.
|
6
|
-
* This class was born live on stage in Sardinia during XP2000.
|
7
|
-
*/
|
8
|
-
public class BaseTestRunner extends Sprite {
|
9
|
-
|
10
|
-
// Filters stack frames from internal JUnit classes
|
11
|
-
public static function getFilteredTrace(stack:String):String {
|
12
|
-
return stack;
|
13
|
-
}
|
14
|
-
}
|
15
|
-
}
|