asunit4 4.2.2.pre → 4.2.3.pre
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/Gemfile.lock +26 -0
- data/bin/AsUnit-4.1.2.swc +0 -0
- data/bin/AsUnit-4.2.3.pre.swc +0 -0
- data/bin/AsUnitRunner.swf +0 -0
- data/bin/Flex4AsUnitRunner.swf +0 -0
- data/build.xml +42 -2
- data/lib/SwiftSuspenders-v1.5.1.swc +0 -0
- data/lib/flexUnitTasks.jar +0 -0
- data/pkg/sprout-asunit4-library-4.1.2.gem +0 -0
- data/rakefile.rb +4 -1
- data/sprout/lib/asunit4.rb +1 -1
- data/src/asunit/asserts/assertMatches.as +6 -0
- data/src/asunit/asserts/assertThrowsWithMessage.as +5 -0
- data/src/asunit/core/AsUnitCore.as +42 -88
- data/src/asunit/core/FlashBuilderCore.as +2 -2
- data/src/asunit/core/FlashDevelopCore.as +1 -1
- data/src/asunit/core/FlexUnitCICore.as +17 -0
- data/src/asunit/core/TextCore.as +36 -54
- data/src/asunit/framework/Assert.as +76 -11
- data/src/asunit/framework/Async.as +1 -1
- data/src/asunit/framework/IResult.as +1 -6
- data/src/asunit/framework/IRunListener.as +0 -3
- data/src/asunit/framework/IRunner.as +0 -3
- data/src/asunit/framework/IRunnerFactory.as +3 -3
- data/src/asunit/framework/ITestListener.as +1 -2
- data/src/asunit/framework/Method.as +82 -80
- data/src/asunit/framework/Result.as +3 -24
- data/src/asunit/framework/RunnerFactory.as +13 -34
- data/src/asunit/framework/SuiteIterator.as +28 -22
- data/src/asunit/framework/TestCase.as +8 -3
- data/src/asunit/printers/FlashBuilderPrinter.as +25 -83
- data/src/asunit/printers/FlashDevelopPrinter.as +1 -2
- data/src/asunit/printers/FlexUnitCIPrinter.as +181 -0
- data/src/asunit/printers/TextPrinter.as +17 -46
- data/src/asunit/printers/XMLPrinter.as +127 -0
- data/src/asunit/runners/LegacyRunner.as +6 -1
- data/src/asunit/runners/SuiteRunner.as +30 -66
- data/src/asunit/runners/TestRunner.as +90 -255
- data/test/AllTests.as +9 -4
- data/test/AsUnitCIRunner.as +18 -0
- data/test/AsUnitRunner.as +2 -0
- data/test/AsUnitRunnerCS3.fla +0 -0
- data/test/asunit/core/AsUnitCoreTest.as +33 -15
- data/test/asunit/framework/AssertEqualsArraysIgnoringOrderTest.as +14 -0
- data/test/asunit/framework/AssertThrowsWithMessageTest.as +50 -0
- data/test/asunit/framework/AsyncTest.as +0 -4
- data/test/asunit/framework/ProceedOnEventTest.as +1 -2
- data/test/asunit/framework/ResultObserverTest.as +61 -0
- data/test/asunit/framework/RunnerFactoryTest.as +7 -9
- data/test/asunit/framework/VisualTestCaseTest.as +2 -26
- data/test/asunit/printers/FlashBuilderPrinterTest.as +18 -0
- data/test/asunit/printers/XMLPrinterTest.as +131 -0
- data/test/asunit/runners/LegacyRunnerTest.as +4 -4
- data/test/asunit/runners/SuiteRunnerTest.as +10 -7
- data/test/asunit/runners/TestRunnerAsyncMethodTest.as +9 -7
- data/test/asunit/runners/TestRunnerErrorMethodTest.as +1 -1
- data/test/asunit/runners/TestRunnerExpectsErrorTest.as +2 -2
- data/test/asunit/runners/TestRunnerExpectsErrorWithMessageTest.as +125 -0
- data/test/asunit/runners/TestRunnerIgnoredMethodTest.as +2 -3
- data/test/asunit/runners/TestRunnerTest.as +4 -27
- data/test/asunit/support/{CustomTestRunner.as → CustomSuiteRunner.as} +7 -3
- data/test/asunit/support/InjectionVerification.as +2 -30
- data/test/asunit/support/SuiteWithCustomRunner.as +1 -1
- data/vendor/as3injection/org/swiftsuspenders/InjectionConfig.as +78 -0
- data/vendor/as3injection/org/swiftsuspenders/InjectionType.as +16 -0
- data/vendor/as3injection/org/swiftsuspenders/Injector.as +376 -0
- data/vendor/as3injection/org/swiftsuspenders/InjectorError.as +17 -0
- data/vendor/as3injection/org/swiftsuspenders/Reflector.as +95 -0
- data/vendor/as3injection/org/swiftsuspenders/getConstructor.as +33 -0
- data/vendor/as3injection/org/swiftsuspenders/injectionpoints/ConstructorInjectionPoint.as +94 -0
- data/vendor/as3injection/org/swiftsuspenders/injectionpoints/InjectionPoint.as +35 -0
- data/vendor/as3injection/org/swiftsuspenders/injectionpoints/MethodInjectionPoint.as +122 -0
- data/vendor/as3injection/org/swiftsuspenders/injectionpoints/NoParamsConstructorInjectionPoint.as +24 -0
- data/vendor/as3injection/org/swiftsuspenders/injectionpoints/PostConstructInjectionPoint.as +52 -0
- data/vendor/as3injection/org/swiftsuspenders/injectionpoints/PropertyInjectionPoint.as +62 -0
- data/vendor/as3injection/org/swiftsuspenders/injectionresults/InjectClassResult.as +33 -0
- data/vendor/as3injection/org/swiftsuspenders/injectionresults/InjectOtherRuleResult.as +34 -0
- data/vendor/as3injection/org/swiftsuspenders/injectionresults/InjectSingletonResult.as +43 -0
- data/vendor/as3injection/org/swiftsuspenders/injectionresults/InjectValueResult.as +33 -0
- data/vendor/as3injection/org/swiftsuspenders/injectionresults/InjectionResult.as +26 -0
- metadata +44 -19
- data/bin/AsUnit-4.2.1.pre.swc +0 -0
- data/bin/AsUnit-4.2.2.pre.swc +0 -0
- data/src/asunit/framework/CallbackBridge.as +0 -175
- data/src/asunit/framework/ITestResult.as +0 -21
- data/src/asunit/framework/InjectionDelegate.as +0 -96
- data/src/asunit/framework/MessageBridge.as +0 -24
- data/src/asunit/framework/TestObserver.as +0 -12
- data/test/asunit/framework/CallbackBridgeTest.as +0 -73
- data/test/asunit/framework/InjectionDelegateTest.as +0 -79
- data/test/asunit/support/AnnotatedSubClass.as +0 -18
- data/test/asunit/support/AnnotatedSuperClass.as +0 -15
- data/test/asunit/support/FakeRunner.as +0 -32
- data/test/asunit/support/InjectTimeoutOnAsync.as +0 -14
- data/test/asunit/support/TestForFakeRunner.as +0 -14
@@ -1,26 +1,22 @@
|
|
1
|
-
package asunit.framework {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
import
|
6
|
-
|
7
|
-
|
8
|
-
import p2.reflect.ReflectionVariable;
|
9
|
-
import p2.reflect.ReflectionMetaData;
|
1
|
+
package asunit.framework {
|
2
|
+
import asunit.util.Iterator;
|
3
|
+
|
4
|
+
import p2.reflect.Reflection;
|
5
|
+
import p2.reflect.ReflectionVariable;
|
6
|
+
|
7
|
+
import flash.utils.getDefinitionByName;
|
10
8
|
|
11
9
|
public class SuiteIterator implements Iterator {
|
12
10
|
|
13
11
|
protected var index:int;
|
14
12
|
protected var list:Array;
|
15
13
|
|
16
|
-
public function SuiteIterator(Suite:Class
|
17
|
-
list = getTestClasses(Suite
|
14
|
+
public function SuiteIterator(Suite:Class) {
|
15
|
+
list = getTestClasses(Suite);
|
18
16
|
}
|
19
17
|
|
20
|
-
private function getTestClasses(Suite:Class
|
21
|
-
|
22
|
-
|
23
|
-
var reflection:Reflection = Reflection.create(Suite);
|
18
|
+
private function getTestClasses(Suite:Class):Array {
|
19
|
+
var reflection:Reflection = Reflection.create(Suite);
|
24
20
|
|
25
21
|
if(!isSuite(reflection) && isTest(reflection)) {
|
26
22
|
return [Suite];
|
@@ -31,16 +27,24 @@ package asunit.framework {
|
|
31
27
|
var response:Array = [];
|
32
28
|
for each(variable in reflection.variables) {
|
33
29
|
TestConstructor = Class(getDefinitionByName(variable.type));
|
34
|
-
if(isSuite(Reflection.create(TestConstructor))) {
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
30
|
+
if(isSuite(Reflection.create(TestConstructor))) {
|
31
|
+
var testClasses:Array = getTestClasses(TestConstructor);
|
32
|
+
for each(var testClass:Class in testClasses) {
|
33
|
+
pushIfNotInArray(testClass, response);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
else {
|
37
|
+
pushIfNotInArray(TestConstructor, response)
|
39
38
|
}
|
40
39
|
}
|
41
40
|
response.sort();
|
42
41
|
return response;
|
43
|
-
}
|
42
|
+
}
|
43
|
+
|
44
|
+
private function pushIfNotInArray(item:Object, array:Array):void {
|
45
|
+
if (array.indexOf(item) >= 0) return;
|
46
|
+
array[array.length] = item;
|
47
|
+
}
|
44
48
|
|
45
49
|
public function get length():uint {
|
46
50
|
return list.length;
|
@@ -58,7 +62,9 @@ package asunit.framework {
|
|
58
62
|
return list[index] != null;
|
59
63
|
}
|
60
64
|
|
61
|
-
|
65
|
+
/**
|
66
|
+
* Returns a test Class.
|
67
|
+
*/
|
62
68
|
public function next():* {
|
63
69
|
return list[index++];
|
64
70
|
}
|
@@ -44,8 +44,7 @@ package asunit.framework {
|
|
44
44
|
}
|
45
45
|
|
46
46
|
protected function addChild(child:DisplayObject):DisplayObject {
|
47
|
-
context.addChild(child);
|
48
|
-
return child;
|
47
|
+
return context.addChild(child);
|
49
48
|
}
|
50
49
|
|
51
50
|
protected function removeChild(child:DisplayObject):DisplayObject {
|
@@ -71,6 +70,12 @@ package asunit.framework {
|
|
71
70
|
Assert.assertThrows(errorType, block);
|
72
71
|
}
|
73
72
|
|
73
|
+
protected function assertThrowsWithMessage(errorType:Class,
|
74
|
+
errorMessage:String,
|
75
|
+
block:Function):void {
|
76
|
+
Assert.assertThrowsWithMessage(errorType, errorMessage, block);
|
77
|
+
}
|
78
|
+
|
74
79
|
protected function assertEquals(...args:Array):void {
|
75
80
|
Assert.assertEquals.apply(null, args);
|
76
81
|
}
|
@@ -92,7 +97,7 @@ package asunit.framework {
|
|
92
97
|
}
|
93
98
|
|
94
99
|
protected function assertEqualsFloat(...args:Array):void {
|
95
|
-
Assert.
|
100
|
+
Assert.assertEqualsFloat.apply(null, args);
|
96
101
|
}
|
97
102
|
|
98
103
|
protected function assertEqualsArrays(...args:Array):void {
|
@@ -1,29 +1,34 @@
|
|
1
1
|
package asunit.printers {
|
2
2
|
import asunit.framework.ITestFailure;
|
3
3
|
import asunit.framework.ITestWarning;
|
4
|
-
|
5
4
|
import asunit.framework.IResult;
|
6
5
|
import asunit.framework.IRunListener;
|
7
6
|
import asunit.framework.ITestSuccess;
|
8
7
|
import asunit.framework.Method;
|
9
|
-
import asunit.framework.TestObserver;
|
10
8
|
|
11
9
|
import flash.events.Event;
|
12
10
|
import flash.events.IOErrorEvent;
|
13
11
|
import flash.events.SecurityErrorEvent;
|
14
|
-
import flash.net.XMLSocket;
|
15
12
|
import flash.utils.getQualifiedClassName;
|
13
|
+
import flash.net.XMLSocket;
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
/**
|
16
|
+
* FlashBuilderPrinter should connect to the running Flash Builder test result
|
17
|
+
* view over an XMLSocket and send it test results as they accumulate.
|
18
|
+
*/
|
19
|
+
public class FlashBuilderPrinter extends XMLPrinter {
|
20
|
+
|
21
21
|
protected var socket:XMLSocket;
|
22
|
-
|
22
|
+
|
23
23
|
public function FlashBuilderPrinter(projectName:String = '', contextName:String = '') {
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
testPrefix = null;
|
25
|
+
testSuffix = null;
|
26
|
+
traceResults = false;
|
27
|
+
super(projectName, contextName);
|
28
|
+
connectToSocket();
|
29
|
+
}
|
30
|
+
|
31
|
+
protected function connectToSocket():void {
|
27
32
|
socket = new XMLSocket();
|
28
33
|
socket.addEventListener(Event.CONNECT, onConnect);
|
29
34
|
socket.addEventListener(IOErrorEvent.IO_ERROR, onErrorEvent);
|
@@ -32,41 +37,8 @@ package asunit.printers {
|
|
32
37
|
connect();
|
33
38
|
}
|
34
39
|
|
35
|
-
|
36
|
-
|
37
|
-
+ "' contextName='" + contextName +"' />");
|
38
|
-
}
|
39
|
-
|
40
|
-
public function onTestStarted(test:Object):void {
|
41
|
-
}
|
42
|
-
|
43
|
-
public function onTestCompleted(test:Object):void {
|
44
|
-
}
|
45
|
-
|
46
|
-
// works for both errors and failures
|
47
|
-
public function onTestFailure(failure:ITestFailure):void {
|
48
|
-
sendMessage(getFailureMessage(failure));
|
49
|
-
}
|
50
|
-
|
51
|
-
public function onTestSuccess(success:ITestSuccess):void {
|
52
|
-
var xmlMessageSuccess:String = "<testCase name='" + success.method
|
53
|
-
+ "' testSuite='" + getQualifiedClassName(success.test) + "' status='success'/>";
|
54
|
-
sendMessage(xmlMessageSuccess);
|
55
|
-
}
|
56
|
-
|
57
|
-
public function onTestIgnored(method:Method):void {
|
58
|
-
var xmlMessageIgnore:String = "<testCase name='" + method.name
|
59
|
-
+ "' testSuite='" + getQualifiedClassName(method.scope) + "' status='ignore'/>";
|
60
|
-
sendMessage(xmlMessageIgnore);
|
61
|
-
}
|
62
|
-
|
63
|
-
public function onWarning(warning:ITestWarning):void {
|
64
|
-
//TODO: is there any way to send a warning to Flash Builder?
|
65
|
-
}
|
66
|
-
|
67
|
-
public function onRunCompleted(result:IResult):void {
|
68
|
-
sendMessage('<endOfTestRun/>');
|
69
|
-
socket.close();
|
40
|
+
protected function onErrorEvent(event:Event):void {
|
41
|
+
trace('FlashBuilderPrinter::onErrorEvent() - event: ' + event);
|
70
42
|
}
|
71
43
|
|
72
44
|
protected function connect(ip:String = '127.0.0.1', port:uint = 8765):void {
|
@@ -77,6 +49,11 @@ package asunit.printers {
|
|
77
49
|
trace('## Error connecting to Flash Builder socket: ' + e.message);
|
78
50
|
}
|
79
51
|
}
|
52
|
+
|
53
|
+
override public function onRunCompleted(result:IResult):void {
|
54
|
+
super.onRunCompleted(result);
|
55
|
+
socket.close();
|
56
|
+
}
|
80
57
|
|
81
58
|
protected function onConnect(event:Event):void {
|
82
59
|
sendQueuedMessages();
|
@@ -88,47 +65,12 @@ package asunit.printers {
|
|
88
65
|
}
|
89
66
|
}
|
90
67
|
|
91
|
-
protected function sendMessage(message:String):void {
|
68
|
+
override protected function sendMessage(message:String):void {
|
92
69
|
if (!socket.connected) {
|
93
70
|
messageQueue.push(message);
|
94
71
|
return;
|
95
72
|
}
|
96
73
|
socket.send(message);
|
97
|
-
//trace('+++++++++ sendMessage() - \n' + message + '\n');
|
98
74
|
}
|
99
|
-
|
100
|
-
protected function getFailureMessage(failure:ITestFailure):String {
|
101
|
-
var status:String = failure.isFailure ? 'failure' : 'error';
|
102
|
-
var xml:String =
|
103
|
-
"<testCase name='" + failure.failedMethod
|
104
|
-
+ "' testSuite='" + getQualifiedClassName(failure.failedTest)
|
105
|
-
+ "' status='" + status + "'>"
|
106
|
-
+ "<failure type='" + getQualifiedClassName(failure.thrownException) + "' >"
|
107
|
-
|
108
|
-
+ "<messageInfo>" + xmlEscapeMessage(failure.exceptionMessage)
|
109
|
-
+ "</messageInfo>"
|
110
|
-
|
111
|
-
+ "<stackTraceInfo>" + xmlEscapeMessage(failure.thrownException.getStackTrace())
|
112
|
-
+ "</stackTraceInfo>"
|
113
|
-
|
114
|
-
+ "</failure>"
|
115
|
-
+ "</testCase>";
|
116
|
-
|
117
|
-
return xml;
|
118
|
-
}
|
119
|
-
|
120
|
-
protected function onErrorEvent(event:Event):void {
|
121
|
-
trace('FlashBuilderPrinter::onErrorEvent() - event: ' + event);
|
122
|
-
//throw new Error('FlashBuilderPrinter::onErrorEvent() - event: ' + event);
|
123
|
-
}
|
124
|
-
|
125
|
-
protected static function xmlEscapeMessage(message:String):String {
|
126
|
-
if (!message) return '';
|
127
|
-
|
128
|
-
var escape:XML = <escape/>;
|
129
|
-
escape.setChildren( message );
|
130
|
-
return escape.children()[0].toXMLString();
|
131
|
-
}
|
132
|
-
|
133
|
-
}
|
75
|
+
}
|
134
76
|
}
|
@@ -6,9 +6,8 @@ package asunit.printers {
|
|
6
6
|
import asunit.framework.IRunListener;
|
7
7
|
import asunit.framework.ITestSuccess;
|
8
8
|
import asunit.framework.Method;
|
9
|
-
import asunit.framework.TestObserver;
|
10
9
|
|
11
|
-
public class FlashDevelopPrinter implements IRunListener
|
10
|
+
public class FlashDevelopPrinter implements IRunListener {
|
12
11
|
protected static const localPathPattern:RegExp =
|
13
12
|
/([A-Z]:\\[^\/:\*\?<>\|]+\.\w{2,6})|(\\{2}[^\/:\*\?<>\|]+\.\w{2,6})/g;
|
14
13
|
|
@@ -0,0 +1,181 @@
|
|
1
|
+
package asunit.printers {
|
2
|
+
import asunit.framework.IResult;
|
3
|
+
import asunit.framework.IRunListener;
|
4
|
+
import asunit.framework.ITestFailure;
|
5
|
+
import asunit.framework.ITestSuccess;
|
6
|
+
import asunit.framework.ITestWarning;
|
7
|
+
import asunit.framework.Method;
|
8
|
+
|
9
|
+
import flash.events.DataEvent;
|
10
|
+
import flash.events.Event;
|
11
|
+
import flash.events.EventDispatcher;
|
12
|
+
import flash.events.IOErrorEvent;
|
13
|
+
import flash.events.SecurityErrorEvent;
|
14
|
+
import flash.events.TimerEvent;
|
15
|
+
import flash.net.XMLSocket;
|
16
|
+
import flash.system.fscommand;
|
17
|
+
import flash.utils.Timer;
|
18
|
+
import flash.utils.getQualifiedClassName;
|
19
|
+
import flash.utils.getTimer;
|
20
|
+
|
21
|
+
public class FlexUnitCIPrinter extends EventDispatcher implements IRunListener
|
22
|
+
{
|
23
|
+
protected static const DEFAULT_SERVER:String = "127.0.0.1";
|
24
|
+
protected static const DEFAULT_PORT:uint = 1024;
|
25
|
+
|
26
|
+
public var port:uint;
|
27
|
+
public var server:String; //this is local host. same machine
|
28
|
+
|
29
|
+
private static const SUCCESS:String = "success";
|
30
|
+
private static const ERROR:String = "error";
|
31
|
+
private static const FAILURE:String = "failure";
|
32
|
+
private static const IGNORE:String = "ignore";
|
33
|
+
|
34
|
+
private static const START_OF_TEST_RUN_ACK : String = "<startOfTestRunAck/>";
|
35
|
+
private static const END_OF_TEST_ACK : String ="<endOfTestRunAck/>";
|
36
|
+
private static const END_OF_TEST_RUN : String = "<endOfTestRun/>";
|
37
|
+
|
38
|
+
private var socket:XMLSocket;
|
39
|
+
private var connectTimeout:Timer;
|
40
|
+
|
41
|
+
protected var messageQueue:Array;
|
42
|
+
|
43
|
+
private var startTime : int;
|
44
|
+
|
45
|
+
public function FlexUnitCIPrinter()
|
46
|
+
{
|
47
|
+
this.port = port;
|
48
|
+
this.server = server;
|
49
|
+
messageQueue = [];
|
50
|
+
|
51
|
+
socket = new XMLSocket();
|
52
|
+
socket.addEventListener(Event.CONNECT, onConnect);
|
53
|
+
socket.addEventListener(DataEvent.DATA, onData);
|
54
|
+
socket.addEventListener(IOErrorEvent.IO_ERROR, onErrorEvent);
|
55
|
+
socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onErrorEvent);
|
56
|
+
socket.addEventListener(Event.CLOSE, onErrorEvent);
|
57
|
+
|
58
|
+
connectTimeout = new Timer(5000, 1);
|
59
|
+
connectTimeout.addEventListener(TimerEvent.TIMER_COMPLETE, onConnectTimeout);
|
60
|
+
connectTimeout.start();
|
61
|
+
|
62
|
+
connect();
|
63
|
+
}
|
64
|
+
|
65
|
+
protected function connect(ip:String = DEFAULT_SERVER, port:uint = DEFAULT_PORT):void {
|
66
|
+
try {
|
67
|
+
socket.connect(ip, port);
|
68
|
+
}
|
69
|
+
catch (e:Error) {
|
70
|
+
trace('## Error connecting to socket: ' + e.message);
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
private function onConnectTimeout(event:TimerEvent):void {
|
75
|
+
throw new Error('Timed out waiting to connect to socket.');
|
76
|
+
}
|
77
|
+
|
78
|
+
public function onTestIgnored(method:Method):void {
|
79
|
+
var xmlMessageIgnore:String = "<testcase classname='" + getQualifiedClassName(method.scope)
|
80
|
+
+ "' name='" + method.name + "' status='"+IGNORE+"'>"
|
81
|
+
+ "<skipped />"
|
82
|
+
+ "</testcase>";
|
83
|
+
sendMessage(xmlMessageIgnore);
|
84
|
+
}
|
85
|
+
|
86
|
+
protected static function xmlEscapeMessage(message:String):String {
|
87
|
+
if (!message) return '';
|
88
|
+
|
89
|
+
var escape:XML = <escape/>;
|
90
|
+
escape.setChildren( message );
|
91
|
+
return escape.children()[0].toXMLString();
|
92
|
+
}
|
93
|
+
|
94
|
+
public function onTestFailure(failure:ITestFailure):void {
|
95
|
+
sendMessage(getFailureMessage(failure));
|
96
|
+
}
|
97
|
+
|
98
|
+
protected function getFailureMessage(failure:ITestFailure):String {
|
99
|
+
var status:String = failure.isFailure ? FAILURE : ERROR;
|
100
|
+
// var stackTrace:String = xmlEscapeMessage(failure.thrownException.getStackTrace());
|
101
|
+
var stackTrace:String = failure.thrownException.getStackTrace();
|
102
|
+
var xml:String =
|
103
|
+
"<testcase classname='" + getQualifiedClassName(failure.failedTest)
|
104
|
+
+ "' name='" + failure.failedMethod
|
105
|
+
+ "' time='0.000' status='" + status + "'>"
|
106
|
+
|
107
|
+
+ "<error message='" + xmlEscapeMessage(failure.exceptionMessage)
|
108
|
+
+ "' type='"+ getQualifiedClassName(failure.thrownException) +"' >"
|
109
|
+
+ "<![CDATA[" + stackTrace + "]]>"
|
110
|
+
+ "</error>"
|
111
|
+
|
112
|
+
+ "</testcase>";
|
113
|
+
|
114
|
+
return xml;
|
115
|
+
}
|
116
|
+
|
117
|
+
protected function sendMessage(message:String):void {
|
118
|
+
if (!socket.connected) {
|
119
|
+
messageQueue.push(message);
|
120
|
+
return;
|
121
|
+
}
|
122
|
+
socket.send(message);
|
123
|
+
}
|
124
|
+
|
125
|
+
protected function onConnect(event:Event):void {
|
126
|
+
connectTimeout.stop();
|
127
|
+
sendQueuedMessages();
|
128
|
+
}
|
129
|
+
|
130
|
+
protected function sendQueuedMessages():void {
|
131
|
+
while (messageQueue.length) {
|
132
|
+
sendMessage(messageQueue.shift());
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
private function onData( event : DataEvent ) : void
|
137
|
+
{
|
138
|
+
if (event.data == END_OF_TEST_ACK) {
|
139
|
+
exit();
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
protected function onErrorEvent(event:Event):void {
|
144
|
+
trace('FlexUnitCIPrinter::onErrorEvent() - event: ' + event);
|
145
|
+
//throw new Error('FlashBuilderPrinter::onErrorEvent() - event: ' + event);
|
146
|
+
}
|
147
|
+
|
148
|
+
public function onRunStarted():void {
|
149
|
+
}
|
150
|
+
|
151
|
+
public function onTestStarted(test:Object):void {
|
152
|
+
startTime = getTimer();
|
153
|
+
}
|
154
|
+
|
155
|
+
public function onTestCompleted(test:Object):void {
|
156
|
+
// testTimes.push({test:test, duration:duration});
|
157
|
+
}
|
158
|
+
|
159
|
+
public function onTestSuccess(success:ITestSuccess):void
|
160
|
+
{
|
161
|
+
//TODO: move test time into ITestSuccess
|
162
|
+
var duration:Number = (getTimer() - startTime) / 1000;
|
163
|
+
var xmlMessageSuccess:String = "<testcase classname='" + getQualifiedClassName(success.test)
|
164
|
+
+ "' name='" + success.method + "' time='0.000' status='"+SUCCESS+"'/>";
|
165
|
+
sendMessage(xmlMessageSuccess);
|
166
|
+
}
|
167
|
+
|
168
|
+
public function onRunCompleted(result:IResult):void {
|
169
|
+
sendMessage(END_OF_TEST_RUN);
|
170
|
+
}
|
171
|
+
|
172
|
+
protected function exit():void
|
173
|
+
{
|
174
|
+
socket.close();
|
175
|
+
fscommand("quit");
|
176
|
+
}
|
177
|
+
|
178
|
+
public function onWarning(warning:ITestWarning) : void {
|
179
|
+
}
|
180
|
+
}
|
181
|
+
}
|