asproject 0.1.21
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +0 -0
- data/History.txt +0 -0
- data/MIT-LICENSE.txt +20 -0
- data/Manifest.txt +16 -0
- data/README.txt +3 -0
- data/TODO.txt +10 -0
- data/bin/asclass +16 -0
- data/bin/asproject +16 -0
- data/lib/asclass.rb +254 -0
- data/lib/asclass_arguments.rb +147 -0
- data/lib/asproject.rb +248 -0
- data/lib/asproject/version.rb +9 -0
- data/lib/asproject_arguments.rb +175 -0
- data/lib/asproject_base.rb +43 -0
- data/lib/asproject_utils.rb +57 -0
- data/lib/eclipse_project.rb +32 -0
- data/lib/path_finder.rb +286 -0
- data/lib/platform.rb +107 -0
- data/lib/project.rb +82 -0
- data/lib/template_resolver.rb +144 -0
- data/lib/test_suite_generator.rb +128 -0
- data/rakefile.rb +85 -0
- data/setup.rb +1585 -0
- data/templates/asclass/as2/Class.as +11 -0
- data/templates/asclass/as2/Component.as +8 -0
- data/templates/asclass/as2/Interface.as +3 -0
- data/templates/asclass/as2/TestCase.as +30 -0
- data/templates/asclass/as2/TestSuite.as +15 -0
- data/templates/asclass/as3/Class.as +9 -0
- data/templates/asclass/as3/Component.as +9 -0
- data/templates/asclass/as3/Component.mxml +1 -0
- data/templates/asclass/as3/Interface.as +6 -0
- data/templates/asclass/as3/TestCase.as +30 -0
- data/templates/asclass/as3/TestSuite.as +18 -0
- data/templates/asproject/as2/project/rakefile.rb +18 -0
- data/templates/asproject/as2/project/src/AsProject.as +13 -0
- data/templates/asproject/as2/project/test/AsProjectRunner.as +12 -0
- data/templates/asproject/as3/project/rakefile.rb +18 -0
- data/templates/asproject/as3/project/src/AsProject.as +9 -0
- data/templates/asproject/as3/project/src/AsProjectRunner.as +11 -0
- data/templates/asproject/asunit2/project/lib/asunit/AsUnitUi.swf +0 -0
- data/templates/asproject/asunit2/project/lib/asunit/Sys.as +70 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanel.as +182 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTest.as +84 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTextArea.as +111 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTextAreaTest.as +26 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTitleBar.as +81 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ResizeHandle.as +35 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollArrow.as +34 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollHandle.as +43 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollListener.as +10 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/TextScroller.as +169 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/shapes/Rectangle.as +29 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/shapes/Triangle.as +27 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/AsUnit.as +19 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Assert.as +408 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Assertion.as +27 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as +68 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Test.as +3 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestCase.as +191 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestCaseXml.as +31 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestFailure.as +15 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestResult.as +15 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestRunner.as +41 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestSetup.as +19 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestSuite.as +22 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/Main.as +325 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/RemoteVersion.as +24 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/SuccessMeter.as +32 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/Comparable.as +7 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/EventListener.as +29 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/EventSource.as +89 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnClient.as +42 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnGateway.as +47 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnServer.as +61 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalMessageBroker.as +58 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/Observable.as +11 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/TextFile.as +30 -0
- data/templates/asproject/asunit25/project/lib/asunit/AsUnitTestRunner.as +13 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/AssertionFailedError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/AssertionPassedError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/ClassNotFoundError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/IllegalOperationError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/InstanceNotFoundError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/InvocationTargetError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/UnimplementedFeatureError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/Assert.as +376 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/AssertMock.as +15 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/AssertTest.as +59 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/ITestListener.as +13 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/Test.as +11 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCase.as +277 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseMock.as +23 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseTest.as +29 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseXml.as +38 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestFailure.as +47 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestResult.as +168 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestSuite.as +102 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/runner/BaseTestRunner.as +101 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/runner/IResultPrinter.as +8 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/ResultPrinter.as +254 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/SuccessBar.as +41 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/TestRunner.as +17 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/ArrayIterator.as +24 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/ArrayIteratorTest.as +52 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/Iterator.as +5 -0
- data/templates/asproject/asunit3/project/lib/asunit/AsUnitTestRunner.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/AbstractMemberCalledError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/AssertionFailedError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/ClassNotFoundError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/InstanceNotFoundError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/UnimplementedFeatureError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/Assert.as +271 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCase.as +52 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCaseExample.as +71 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/Test.as +15 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestCase.as +351 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestCaseExample.as +73 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestFailure.as +47 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestListener.as +22 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestResult.as +158 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestSuite.as +115 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/BaseTestRunner.as +15 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/TestSuiteLoader.as +9 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/Version.as +11 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/FlexRunner.as +19 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/FlexTestRunner.as +55 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/ResultPrinter.as +245 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/TestRunner.as +121 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/ArrayIterator.as +26 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/Iterator.as +9 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/Properties.as +30 -0
- data/templates/asproject/asunit3/project/lib/asunit/mx/managers/LayoutManager.as +945 -0
- data/templates/asproject/config/project/config/asclass_config.rb +58 -0
- data/templates/asproject/fb2as/project/.actionScriptProperties +21 -0
- data/templates/asproject/fb2as/project/.project +29 -0
- data/templates/asproject/fdt/project/.as2_classpath +6 -0
- data/templates/asproject/fdt/project/.project +19 -0
- data/templates/ide/mate/Create Class.tmCommand +37 -0
- data/templates/ide/mate/Rebuild Test Suites.tmCommand +33 -0
- data/templates/ide/mate/Run Rake Task.tmCommand +127 -0
- metadata +266 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
package asunit.textui {
|
2
|
+
import asunit.framework.TestResult;
|
3
|
+
|
4
|
+
import mx.core.Application;
|
5
|
+
|
6
|
+
public class FlexRunner extends Application {
|
7
|
+
protected var runner:TestRunner;
|
8
|
+
|
9
|
+
override protected function createChildren():void {
|
10
|
+
super.createChildren();
|
11
|
+
runner = new FlexTestRunner();
|
12
|
+
rawChildren.addChild(runner);
|
13
|
+
}
|
14
|
+
|
15
|
+
public function start(testCase:Class, testMethod:String = null, showTrace:Boolean = false):TestResult {
|
16
|
+
return runner.start(testCase, testMethod, showTrace);
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
package asunit.textui {
|
2
|
+
import flash.display.DisplayObject;
|
3
|
+
import flash.events.Event;
|
4
|
+
import mx.core.IUIComponent;
|
5
|
+
import asunit.textui.TestRunner;
|
6
|
+
|
7
|
+
public class FlexTestRunner extends TestRunner {
|
8
|
+
|
9
|
+
public function FlexTestRunner() {
|
10
|
+
setPrinter(new ResultPrinter());
|
11
|
+
}
|
12
|
+
|
13
|
+
protected override function addedHandler(event:Event):void {
|
14
|
+
if(event.target === this) {
|
15
|
+
parent.addEventListener(Event.RESIZE, resizeHandler);
|
16
|
+
resizeHandler(new Event(Event.RESIZE));
|
17
|
+
}
|
18
|
+
else {
|
19
|
+
event.stopPropagation();
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
public override function set width(w:Number):void {
|
24
|
+
fPrinter.width = w;
|
25
|
+
}
|
26
|
+
|
27
|
+
public override function set height(h:Number):void {
|
28
|
+
fPrinter.height = h;
|
29
|
+
}
|
30
|
+
|
31
|
+
public function resizeHandler(event:Event):void {
|
32
|
+
width = parent.width;
|
33
|
+
height = parent.height;
|
34
|
+
}
|
35
|
+
|
36
|
+
public override function addChild(child:DisplayObject):DisplayObject {
|
37
|
+
if(parent && child is IUIComponent) {
|
38
|
+
// AND check for 'is' UIUComponent...
|
39
|
+
return parent.addChild(child);
|
40
|
+
}
|
41
|
+
else {
|
42
|
+
return super.addChild(child);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
public override function removeChild(child:DisplayObject):DisplayObject {
|
47
|
+
if(child is IUIComponent) {
|
48
|
+
return parent.removeChild(child);
|
49
|
+
}
|
50
|
+
else {
|
51
|
+
return super.removeChild(child);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
@@ -0,0 +1,245 @@
|
|
1
|
+
package asunit.textui {
|
2
|
+
import asunit.errors.AssertionFailedError;
|
3
|
+
import asunit.framework.Test;
|
4
|
+
import asunit.framework.TestFailure;
|
5
|
+
import asunit.framework.TestListener;
|
6
|
+
import asunit.framework.TestResult;
|
7
|
+
import asunit.runner.BaseTestRunner;
|
8
|
+
import asunit.runner.Version;
|
9
|
+
|
10
|
+
import flash.display.Shape;
|
11
|
+
import flash.display.Sprite;
|
12
|
+
import flash.display.Stage;
|
13
|
+
import flash.display.StageAlign;
|
14
|
+
import flash.display.StageScaleMode;
|
15
|
+
import flash.events.*;
|
16
|
+
import flash.text.TextField;
|
17
|
+
import flash.text.TextFormat;
|
18
|
+
import flash.ui.Keyboard;
|
19
|
+
import flash.utils.setTimeout;
|
20
|
+
|
21
|
+
public class ResultPrinter extends Sprite implements TestListener {
|
22
|
+
private var fColumn:int = 0;
|
23
|
+
private var textArea:TextField;
|
24
|
+
private var gutter:uint = 0;
|
25
|
+
private var backgroundColor:uint = 0x333333;
|
26
|
+
private var bar:SuccessBar;
|
27
|
+
private var barHeight:Number = 3;
|
28
|
+
private var showTrace:Boolean;
|
29
|
+
|
30
|
+
public function ResultPrinter(showTrace:Boolean = false) {
|
31
|
+
this.showTrace = showTrace;
|
32
|
+
configureAssets();
|
33
|
+
println();
|
34
|
+
}
|
35
|
+
|
36
|
+
private function configureAssets():void {
|
37
|
+
textArea = new TextField();
|
38
|
+
textArea.background = true;
|
39
|
+
textArea.backgroundColor = backgroundColor;
|
40
|
+
textArea.border = true;
|
41
|
+
textArea.wordWrap = true;
|
42
|
+
var format:TextFormat = new TextFormat();
|
43
|
+
format.font = "Verdana";
|
44
|
+
format.size = 10;
|
45
|
+
format.color = 0xFFFFFF;
|
46
|
+
textArea.defaultTextFormat = format;
|
47
|
+
addChild(textArea);
|
48
|
+
println("AsUnit " + Version.id() + " by Luke Bayes and Ali Mills");
|
49
|
+
|
50
|
+
bar = new SuccessBar();
|
51
|
+
addChild(bar);
|
52
|
+
}
|
53
|
+
|
54
|
+
public function setShowTrace(showTrace:Boolean):void {
|
55
|
+
this.showTrace = showTrace;
|
56
|
+
}
|
57
|
+
|
58
|
+
public override function set width(w:Number):void {
|
59
|
+
textArea.x = gutter;
|
60
|
+
textArea.width = w - gutter*2;
|
61
|
+
bar.x = gutter;
|
62
|
+
bar.width = textArea.width;
|
63
|
+
}
|
64
|
+
|
65
|
+
public override function set height(h:Number):void {
|
66
|
+
textArea.height = h - ((gutter*2) + barHeight);
|
67
|
+
textArea.y = gutter;
|
68
|
+
bar.y = h - (gutter + barHeight);
|
69
|
+
bar.height = barHeight;
|
70
|
+
}
|
71
|
+
|
72
|
+
public function println(...args:Array):void {
|
73
|
+
textArea.appendText(args.toString() + "\n");
|
74
|
+
}
|
75
|
+
|
76
|
+
public function print(...args:Array):void {
|
77
|
+
textArea.appendText(args.toString());
|
78
|
+
}
|
79
|
+
/* API for use by textui.TestRunner
|
80
|
+
*/
|
81
|
+
|
82
|
+
public function printResult(result:TestResult, runTime:Number):void {
|
83
|
+
printHeader(runTime);
|
84
|
+
printErrors(result);
|
85
|
+
printFailures(result);
|
86
|
+
printFooter(result);
|
87
|
+
|
88
|
+
bar.setSuccess(result.wasSuccessful());
|
89
|
+
if(showTrace) {
|
90
|
+
trace(textArea.text);
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
/* Internal methods
|
95
|
+
*/
|
96
|
+
protected function printHeader(runTime:Number):void {
|
97
|
+
println();
|
98
|
+
println();
|
99
|
+
println("Time: " + elapsedTimeAsString(runTime));
|
100
|
+
}
|
101
|
+
|
102
|
+
protected function printErrors(result:TestResult):void {
|
103
|
+
printDefects(result.errors(), result.errorCount(), "error");
|
104
|
+
}
|
105
|
+
|
106
|
+
protected function printFailures(result:TestResult):void {
|
107
|
+
printDefects(result.failures(), result.failureCount(), "failure");
|
108
|
+
}
|
109
|
+
|
110
|
+
protected function printDefects(booBoos:Object, count:int, type:String):void {
|
111
|
+
if (count == 0) {
|
112
|
+
return;
|
113
|
+
}
|
114
|
+
if (count == 1) {
|
115
|
+
println("There was " + count + " " + type + ":");
|
116
|
+
}
|
117
|
+
else {
|
118
|
+
println("There were " + count + " " + type + "s:");
|
119
|
+
}
|
120
|
+
var i:uint;
|
121
|
+
for each (var item:TestFailure in booBoos) {
|
122
|
+
printDefect(TestFailure(item), i);
|
123
|
+
i++;
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
public function printDefect(booBoo:TestFailure, count:int ):void { // only public for testing purposes
|
128
|
+
printDefectHeader(booBoo, count);
|
129
|
+
printDefectTrace(booBoo);
|
130
|
+
}
|
131
|
+
|
132
|
+
protected function printDefectHeader(booBoo:TestFailure, count:int):void {
|
133
|
+
// I feel like making this a println, then adding a line giving the throwable a chance to print something
|
134
|
+
// before we get to the stack trace.
|
135
|
+
var startIndex:uint = textArea.text.length;
|
136
|
+
println(count + ") " + booBoo.failedTest());
|
137
|
+
var endIndex:uint = textArea.text.length;
|
138
|
+
|
139
|
+
var format:TextFormat = textArea.getTextFormat();
|
140
|
+
format.bold = true;
|
141
|
+
|
142
|
+
// GROSS HACK because of bug in flash player - TextField isn't accepting formats...
|
143
|
+
setTimeout(onFormatTimeout, 1, format, startIndex, endIndex);
|
144
|
+
}
|
145
|
+
|
146
|
+
public function onFormatTimeout(format:TextFormat, startIndex:uint, endIndex:uint):void {
|
147
|
+
textArea.setTextFormat(format, startIndex, endIndex);
|
148
|
+
}
|
149
|
+
|
150
|
+
protected function printDefectTrace(booBoo:TestFailure):void {
|
151
|
+
println(BaseTestRunner.getFilteredTrace(booBoo.thrownException().getStackTrace()));
|
152
|
+
}
|
153
|
+
|
154
|
+
protected function printFooter(result:TestResult):void {
|
155
|
+
println();
|
156
|
+
if (result.wasSuccessful()) {
|
157
|
+
print("OK");
|
158
|
+
println (" (" + result.runCount() + " test" + (result.runCount() == 1 ? "": "s") + ")");
|
159
|
+
} else {
|
160
|
+
println("FAILURES!!!");
|
161
|
+
println("Tests run: " + result.runCount()+
|
162
|
+
", Failures: "+result.failureCount()+
|
163
|
+
", Errors: "+result.errorCount());
|
164
|
+
}
|
165
|
+
println();
|
166
|
+
}
|
167
|
+
|
168
|
+
/**
|
169
|
+
* Returns the formatted string of the elapsed time.
|
170
|
+
* Duplicated from BaseTestRunner. Fix it.
|
171
|
+
*/
|
172
|
+
protected function elapsedTimeAsString(runTime:Number):String {
|
173
|
+
return Number(runTime/1000).toString();
|
174
|
+
}
|
175
|
+
|
176
|
+
/**
|
177
|
+
* @see junit.framework.TestListener#addError(Test, Throwable)
|
178
|
+
*/
|
179
|
+
public function addError(test:Test, t:Error):void {
|
180
|
+
print("E");
|
181
|
+
}
|
182
|
+
|
183
|
+
/**
|
184
|
+
* @see junit.framework.TestListener#addFailure(Test, AssertionFailedError)
|
185
|
+
*/
|
186
|
+
public function addFailure(test:Test, t:AssertionFailedError):void {
|
187
|
+
print("F");
|
188
|
+
}
|
189
|
+
|
190
|
+
/**
|
191
|
+
* @see junit.framework.TestListener#endTest(Test)
|
192
|
+
*/
|
193
|
+
public function endTest(test:Test):void {
|
194
|
+
}
|
195
|
+
|
196
|
+
/**
|
197
|
+
* @see junit.framework.TestListener#startTest(Test)
|
198
|
+
*/
|
199
|
+
public function startTest(test:Test):void {
|
200
|
+
var count:uint = test.countTestCases();
|
201
|
+
for(var i:uint; i < count; i++) {
|
202
|
+
print(".");
|
203
|
+
if (fColumn++ >= 80) {
|
204
|
+
println();
|
205
|
+
fColumn = 0;
|
206
|
+
}
|
207
|
+
}
|
208
|
+
}
|
209
|
+
}
|
210
|
+
}
|
211
|
+
|
212
|
+
import flash.display.Sprite;
|
213
|
+
|
214
|
+
class SuccessBar extends Sprite {
|
215
|
+
private var myWidth:uint;
|
216
|
+
private var myHeight:uint;
|
217
|
+
private var bgColor:uint;
|
218
|
+
private var passingColor:uint = 0x00FF00;
|
219
|
+
private var failingColor:uint = 0xFD0000;
|
220
|
+
|
221
|
+
public function SuccessBar() {
|
222
|
+
}
|
223
|
+
|
224
|
+
public function setSuccess(success:Boolean):void {
|
225
|
+
bgColor = (success) ? passingColor : failingColor;
|
226
|
+
draw();
|
227
|
+
}
|
228
|
+
|
229
|
+
public override function set width(num:Number):void {
|
230
|
+
myWidth = num;
|
231
|
+
draw();
|
232
|
+
}
|
233
|
+
|
234
|
+
public override function set height(num:Number):void {
|
235
|
+
myHeight = num;
|
236
|
+
draw();
|
237
|
+
}
|
238
|
+
|
239
|
+
private function draw():void {
|
240
|
+
graphics.clear();
|
241
|
+
graphics.beginFill(bgColor);
|
242
|
+
graphics.drawRect(0, 0, myWidth, myHeight);
|
243
|
+
graphics.endFill();
|
244
|
+
}
|
245
|
+
}
|
@@ -0,0 +1,121 @@
|
|
1
|
+
package asunit.textui {
|
2
|
+
import asunit.errors.AbstractMemberCalledError;
|
3
|
+
import asunit.framework.Test;
|
4
|
+
import asunit.framework.TestResult;
|
5
|
+
|
6
|
+
import flash.display.Sprite;
|
7
|
+
import flash.display.StageAlign;
|
8
|
+
import flash.display.StageScaleMode;
|
9
|
+
import flash.events.Event;
|
10
|
+
import flash.system.fscommand;
|
11
|
+
import flash.utils.clearInterval;
|
12
|
+
import flash.utils.describeType;
|
13
|
+
import flash.utils.getTimer;
|
14
|
+
import flash.utils.setInterval;
|
15
|
+
import flash.utils.Timer;
|
16
|
+
import flash.events.TimerEvent;
|
17
|
+
|
18
|
+
/**
|
19
|
+
* A command line based tool to run tests.
|
20
|
+
* <pre>
|
21
|
+
* java junit.textui.TestRunner TestCaseClass
|
22
|
+
* </pre>
|
23
|
+
* TestRunner expects the name of a TestCase class as argument.
|
24
|
+
* If this class defines a static <code>suite</code> method it
|
25
|
+
* will be invoked and the returned test is run. Otherwise all
|
26
|
+
* the methods starting with "test" having no arguments are run.
|
27
|
+
* <p>
|
28
|
+
* TestRunner prints a trace as the tests are executed followed by a
|
29
|
+
* summary at the end.
|
30
|
+
*/
|
31
|
+
public class TestRunner extends Sprite {
|
32
|
+
public static const SUCCESS_EXIT:int = 0;
|
33
|
+
public static const FAILURE_EXIT:int = 1;
|
34
|
+
public static const EXCEPTION_EXIT:int = 2;
|
35
|
+
public static const SHOW_TRACE:Boolean = true;
|
36
|
+
protected var fPrinter:ResultPrinter;
|
37
|
+
protected var startTime:Number;
|
38
|
+
protected var result:TestResult;
|
39
|
+
|
40
|
+
public function TestRunner() {
|
41
|
+
configureListeners();
|
42
|
+
}
|
43
|
+
|
44
|
+
private function configureListeners():void {
|
45
|
+
addEventListener(Event.ADDED, addedHandler);
|
46
|
+
}
|
47
|
+
|
48
|
+
protected function addedHandler(event:Event):void {
|
49
|
+
if(event.target === fPrinter) {
|
50
|
+
stage.align = StageAlign.TOP_LEFT;
|
51
|
+
stage.scaleMode = StageScaleMode.NO_SCALE;
|
52
|
+
stage.addEventListener(Event.RESIZE, resizeHandler);
|
53
|
+
resizeHandler(new Event("resize"));
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
private function resizeHandler(event:Event):void {
|
58
|
+
fPrinter.width = stage.stageWidth;
|
59
|
+
fPrinter.height = stage.stageHeight;
|
60
|
+
}
|
61
|
+
|
62
|
+
/**
|
63
|
+
* Starts a test run based on the TestCase/TestSuite provided
|
64
|
+
* Create a new custom class that extends TestRunner
|
65
|
+
* and call start(TestCaseClass) from within the
|
66
|
+
* constructor.
|
67
|
+
*/
|
68
|
+
public function start(testCase:Class, testMethod:String = null, showTrace:Boolean = false):TestResult {
|
69
|
+
// fscommand("showmenu", "false");
|
70
|
+
|
71
|
+
try {
|
72
|
+
var instance:Test;
|
73
|
+
if(testMethod != null) {
|
74
|
+
instance = new testCase(testMethod);
|
75
|
+
}
|
76
|
+
else {
|
77
|
+
instance = new testCase();
|
78
|
+
}
|
79
|
+
return doRun(instance, showTrace);
|
80
|
+
}
|
81
|
+
catch(e:Error) {
|
82
|
+
throw new Error("Could not create and run test suite: " + e.getStackTrace());
|
83
|
+
}
|
84
|
+
return null;
|
85
|
+
}
|
86
|
+
|
87
|
+
public function doRun(test:Test, showTrace:Boolean = false):TestResult {
|
88
|
+
result = new TestResult();
|
89
|
+
if(fPrinter == null) {
|
90
|
+
setPrinter(new ResultPrinter(showTrace));
|
91
|
+
}
|
92
|
+
else {
|
93
|
+
fPrinter.setShowTrace(showTrace);
|
94
|
+
}
|
95
|
+
result.addListener(getPrinter());
|
96
|
+
startTime = getTimer();
|
97
|
+
test.setResult(result);
|
98
|
+
test.setContext(this);
|
99
|
+
test.addEventListener(Event.COMPLETE, testCompleteHandler);
|
100
|
+
test.run();
|
101
|
+
return result;
|
102
|
+
}
|
103
|
+
|
104
|
+
private function testCompleteHandler(event:Event):void {
|
105
|
+
var endTime:Number = getTimer();
|
106
|
+
var runTime:Number = endTime - startTime;
|
107
|
+
getPrinter().printResult(result, runTime);
|
108
|
+
}
|
109
|
+
|
110
|
+
public function setPrinter(printer:ResultPrinter):void {
|
111
|
+
if(fPrinter == null) {
|
112
|
+
fPrinter = printer;
|
113
|
+
addChild(fPrinter);
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
public function getPrinter():ResultPrinter {
|
118
|
+
return fPrinter;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
package asunit.util {
|
2
|
+
|
3
|
+
import asunit.util.Iterator;
|
4
|
+
|
5
|
+
[ExcludeClass]
|
6
|
+
public class ArrayIterator implements Iterator {
|
7
|
+
private var list:Array;
|
8
|
+
private var index:Number = 0;
|
9
|
+
|
10
|
+
public function ArrayIterator(list:Array) {
|
11
|
+
this.list = list;
|
12
|
+
}
|
13
|
+
|
14
|
+
public function hasNext():Boolean {
|
15
|
+
return list[index] != null;
|
16
|
+
}
|
17
|
+
|
18
|
+
public function next():Object {
|
19
|
+
return list[index++];
|
20
|
+
}
|
21
|
+
|
22
|
+
public function reset():void {
|
23
|
+
index = 0;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|