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
data/test/AllTests.as
CHANGED
@@ -11,12 +11,12 @@ package {
|
|
11
11
|
import asunit.framework.AssertEqualsArraysTest;
|
12
12
|
import asunit.framework.AssertTest;
|
13
13
|
import asunit.framework.AssertThrowsTest;
|
14
|
+
import asunit.framework.AssertThrowsWithMessageTest;
|
14
15
|
import asunit.framework.AsyncMethodTest;
|
15
16
|
import asunit.framework.AsyncTest;
|
16
|
-
import asunit.framework.CallbackBridgeTest;
|
17
|
-
import asunit.framework.InjectionDelegateTest;
|
18
17
|
import asunit.framework.NestedSuiteIteratorTest;
|
19
18
|
import asunit.framework.ProceedOnEventTest;
|
19
|
+
import asunit.framework.ResultObserverTest;
|
20
20
|
import asunit.framework.ResultTest;
|
21
21
|
import asunit.framework.RunnerFactoryTest;
|
22
22
|
import asunit.framework.SuiteIteratorTest;
|
@@ -27,11 +27,14 @@ package {
|
|
27
27
|
import asunit.framework.TestIteratorSingleMethodTest;
|
28
28
|
import asunit.framework.VisualTestCaseTest;
|
29
29
|
import asunit.printers.TextPrinterTest;
|
30
|
+
import asunit.printers.XMLPrinterTest;
|
31
|
+
import asunit.printers.FlashBuilderPrinterTest;
|
30
32
|
import asunit.runners.LegacyRunnerTest;
|
31
33
|
import asunit.runners.SuiteRunnerTest;
|
32
34
|
import asunit.runners.TestRunnerAsyncMethodTest;
|
33
35
|
import asunit.runners.TestRunnerErrorMethodTest;
|
34
36
|
import asunit.runners.TestRunnerExpectsErrorTest;
|
37
|
+
import asunit.runners.TestRunnerExpectsErrorWithMessageTest;
|
35
38
|
import asunit.runners.TestRunnerIgnoredMethodTest;
|
36
39
|
import asunit.runners.TestRunnerTest;
|
37
40
|
import asunit.util.ArrayIteratorTest;
|
@@ -43,13 +46,13 @@ package {
|
|
43
46
|
public var asunit_framework_AssertEqualsArraysIgnoringOrderTest:asunit.framework.AssertEqualsArraysIgnoringOrderTest;
|
44
47
|
public var asunit_framework_AssertEqualsArraysTest:asunit.framework.AssertEqualsArraysTest;
|
45
48
|
public var asunit_framework_AssertTest:asunit.framework.AssertTest;
|
49
|
+
public var asunit_framework_AssertThrowsWithMessageTest:asunit.framework.AssertThrowsWithMessageTest;
|
46
50
|
public var asunit_framework_AssertThrowsTest:asunit.framework.AssertThrowsTest;
|
47
51
|
public var asunit_framework_AsyncMethodTest:asunit.framework.AsyncMethodTest;
|
48
52
|
public var asunit_framework_AsyncTest:asunit.framework.AsyncTest;
|
49
|
-
public var asunit_framework_CallbackBridgeTest:asunit.framework.CallbackBridgeTest;
|
50
|
-
public var asunit_framework_InjectionDelegateTest:asunit.framework.InjectionDelegateTest;
|
51
53
|
public var asunit_framework_NestedSuiteIteratorTest:asunit.framework.NestedSuiteIteratorTest;
|
52
54
|
public var asunit_framework_ProceedOnEventTest:asunit.framework.ProceedOnEventTest;
|
55
|
+
public var asunit_framework_ResultObserverTest:asunit.framework.ResultObserverTest;
|
53
56
|
public var asunit_framework_ResultTest:asunit.framework.ResultTest;
|
54
57
|
public var asunit_framework_RunnerFactoryTest:asunit.framework.RunnerFactoryTest;
|
55
58
|
public var asunit_framework_SuiteIteratorTest:asunit.framework.SuiteIteratorTest;
|
@@ -60,11 +63,13 @@ package {
|
|
60
63
|
public var asunit_framework_TestIteratorSingleMethodTest:asunit.framework.TestIteratorSingleMethodTest;
|
61
64
|
public var asunit_framework_VisualTestCaseTest:asunit.framework.VisualTestCaseTest;
|
62
65
|
public var asunit_printers_TextPrinterTest:asunit.printers.TextPrinterTest;
|
66
|
+
public var asunit_printers_FlashBuilderPrinterTest:asunit.printers.FlashBuilderPrinterTest;
|
63
67
|
public var asunit_runners_LegacyRunnerTest:asunit.runners.LegacyRunnerTest;
|
64
68
|
public var asunit_runners_SuiteRunnerTest:asunit.runners.SuiteRunnerTest;
|
65
69
|
public var asunit_runners_TestRunnerAsyncMethodTest:asunit.runners.TestRunnerAsyncMethodTest;
|
66
70
|
public var asunit_runners_TestRunnerErrorMethodTest:asunit.runners.TestRunnerErrorMethodTest;
|
67
71
|
public var asunit_runners_TestRunnerExpectsErrorTest:asunit.runners.TestRunnerExpectsErrorTest;
|
72
|
+
public var asunit_runners_TestRunnerExpectsErrorWithMessageTest:asunit.runners.TestRunnerExpectsErrorWithMessageTest;
|
68
73
|
public var asunit_runners_TestRunnerIgnoredMethodTest:asunit.runners.TestRunnerIgnoredMethodTest;
|
69
74
|
public var asunit_runners_TestRunnerTest:asunit.runners.TestRunnerTest;
|
70
75
|
public var asunit_util_ArrayIteratorTest:asunit.util.ArrayIteratorTest;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
package {
|
2
|
+
|
3
|
+
import asunit.core.FlexUnitCICore;
|
4
|
+
import asunit.core.TextCore;
|
5
|
+
|
6
|
+
import flash.display.MovieClip;
|
7
|
+
|
8
|
+
[SWF(width="1024", height="640", backgroundColor="#000000", frameRate="61")]
|
9
|
+
public class AsUnitCIRunner extends MovieClip {
|
10
|
+
|
11
|
+
private var core:TextCore;
|
12
|
+
|
13
|
+
public function AsUnitCIRunner() {
|
14
|
+
core = new FlexUnitCICore();
|
15
|
+
core.start(AllTests, null, this);
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
data/test/AsUnitRunner.as
CHANGED
@@ -3,12 +3,14 @@ package {
|
|
3
3
|
import asunit.core.TextCore;
|
4
4
|
import flash.display.MovieClip;
|
5
5
|
|
6
|
+
[SWF(width="1024", height="640", backgroundColor="#000000", frameRate="61")]
|
6
7
|
public class AsUnitRunner extends MovieClip {
|
7
8
|
|
8
9
|
private var core:TextCore;
|
9
10
|
|
10
11
|
public function AsUnitRunner() {
|
11
12
|
core = new TextCore();
|
13
|
+
core.textPrinter.hideLocalPaths = true;
|
12
14
|
core.start(AllTests, null, this);
|
13
15
|
}
|
14
16
|
}
|
Binary file
|
@@ -1,12 +1,11 @@
|
|
1
1
|
package asunit.core {
|
2
2
|
|
3
3
|
import asunit.asserts.*;
|
4
|
-
import asunit.framework.CallbackBridge;
|
5
4
|
import asunit.framework.IAsync;
|
6
5
|
import asunit.framework.IResult;
|
7
6
|
import asunit.framework.Result;
|
8
7
|
import asunit.printers.TextPrinter;
|
9
|
-
import asunit.support.
|
8
|
+
import asunit.support.CustomSuiteRunner;
|
10
9
|
import asunit.support.SuiteWithCustomRunner;
|
11
10
|
import asunit.support.SuiteWithOneCustomChildSuite;
|
12
11
|
import asunit.support.SucceedAssertTrue;
|
@@ -19,15 +18,16 @@ package asunit.core {
|
|
19
18
|
[Inject]
|
20
19
|
public var async:IAsync;
|
21
20
|
|
22
|
-
|
23
|
-
public var core:AsUnitCore;
|
21
|
+
private var core:AsUnitCore;
|
24
22
|
|
25
|
-
|
26
|
-
|
23
|
+
[Before]
|
24
|
+
public function setUp():void {
|
25
|
+
core = new AsUnitCore();
|
26
|
+
}
|
27
27
|
|
28
28
|
[After]
|
29
29
|
public function cleanUpStatics():void {
|
30
|
-
|
30
|
+
CustomSuiteRunner.runCalledCount = 0;
|
31
31
|
}
|
32
32
|
|
33
33
|
[Test]
|
@@ -39,18 +39,36 @@ package asunit.core {
|
|
39
39
|
public function startShouldWork():void {
|
40
40
|
core.start(SucceedAssertTrue);
|
41
41
|
}
|
42
|
+
|
43
|
+
[Test]
|
44
|
+
public function shouldDispatchSelfAsCurrentTarget():void {
|
45
|
+
var handlerCalled:Boolean = false;
|
46
|
+
var handler:Function = function(event:Event):void {
|
47
|
+
assertSame("currentTarget should be the core", core, event.currentTarget);
|
48
|
+
handlerCalled = true;
|
49
|
+
core.removeEventListener(event.type, arguments.callee);
|
50
|
+
}
|
51
|
+
|
52
|
+
var eventType:String = "foo";
|
53
|
+
core.addEventListener(eventType, handler);
|
54
|
+
// when
|
55
|
+
core.dispatchEvent(new Event(eventType));
|
56
|
+
// then
|
57
|
+
assertTrue("handler called", handlerCalled);
|
58
|
+
}
|
42
59
|
|
43
60
|
[Test]
|
44
61
|
public function setVisualContextShouldWork():void {
|
62
|
+
var context:Sprite = new Sprite();
|
45
63
|
core.visualContext = context;
|
46
|
-
|
64
|
+
assertSame(context, core.visualContext);
|
47
65
|
}
|
48
66
|
|
49
67
|
[Test]
|
50
68
|
public function textPrinterShouldWork():void {
|
51
69
|
var printer:TextPrinter = new TextPrinter();
|
52
70
|
printer.traceOnComplete = false;
|
53
|
-
core.
|
71
|
+
core.addListener(printer);
|
54
72
|
|
55
73
|
// Wait for the complete event:
|
56
74
|
var handler:Function = function(event:Event):void {
|
@@ -66,11 +84,11 @@ package asunit.core {
|
|
66
84
|
private function verifyRunWithOnASuite(Suite:Class, testCaseCount:int, testMethodCount:int):void {
|
67
85
|
|
68
86
|
var handler:Function = function(event:Event):void {
|
69
|
-
var message:String = "
|
87
|
+
var message:String = "CustomSuiteRunner.run was NOT called with correct count";
|
70
88
|
// This is the number of Tests that will used the custom Runner:
|
71
|
-
assertEquals(message, testCaseCount,
|
89
|
+
assertEquals(message, testCaseCount, CustomSuiteRunner.runCalledCount);
|
72
90
|
// This is the number of test methods:
|
73
|
-
assertEquals("Total Test Count", testMethodCount, core.
|
91
|
+
assertEquals("Total Test Count", testMethodCount, core.result.runCount);
|
74
92
|
}
|
75
93
|
|
76
94
|
core.addEventListener(Event.COMPLETE, async.add(handler, 200));
|
@@ -78,9 +96,9 @@ package asunit.core {
|
|
78
96
|
}
|
79
97
|
|
80
98
|
[Test]
|
81
|
-
public function
|
82
|
-
//
|
83
|
-
var testCaseCount:int =
|
99
|
+
public function shouldUseRunWithOnlyOnItsSuiteNotChildren():void {
|
100
|
+
// TheRunWith is on the outer Suite:
|
101
|
+
var testCaseCount:int = 1;
|
84
102
|
var testMethodCount:int = 4;
|
85
103
|
verifyRunWithOnASuite(SuiteWithCustomRunner, testCaseCount, testMethodCount);
|
86
104
|
}
|
@@ -3,6 +3,7 @@
|
|
3
3
|
import asunit.errors.AssertionFailedError;
|
4
4
|
import asunit.framework.TestCase;
|
5
5
|
import asunit.framework.Assert;
|
6
|
+
import flash.display.Sprite;
|
6
7
|
|
7
8
|
/**
|
8
9
|
* Tests assertEqualsArraysIgnoringOrder
|
@@ -84,5 +85,18 @@
|
|
84
85
|
public function testArrayDifferentLength2():void {
|
85
86
|
assertAssertionFailed(Assert.assertEqualsArraysIgnoringOrder, ["abc", "def"], ["abc", "def", "ghi"]);
|
86
87
|
}
|
88
|
+
|
89
|
+
public function testArrayWithRepeatedItems():void {
|
90
|
+
var spr1:Sprite = new Sprite();
|
91
|
+
var spr2:Sprite = new Sprite();
|
92
|
+
var spr3:Sprite = new Sprite();
|
93
|
+
|
94
|
+
var controlArray:Array = [spr1, spr2, spr3, spr1];
|
95
|
+
var matchingArray:Array = [spr1, spr2, spr1, spr3];
|
96
|
+
var nonMatchingArray:Array = [spr1, spr2, spr3, spr2];
|
97
|
+
|
98
|
+
assertEqualsArraysIgnoringOrder('these arrays should match', controlArray, matchingArray);
|
99
|
+
assertAssertionFailed(Assert.assertEqualsArraysIgnoringOrder, controlArray, nonMatchingArray);
|
100
|
+
}
|
87
101
|
}
|
88
102
|
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
package asunit.framework {
|
2
|
+
|
3
|
+
import asunit.asserts.*;
|
4
|
+
import asunit.errors.AssertionFailedError;
|
5
|
+
|
6
|
+
public class AssertThrowsWithMessageTest {
|
7
|
+
|
8
|
+
[Test]
|
9
|
+
public function throwingExpectedErrorShouldPass():void {
|
10
|
+
assertThrowsWithMessage(ArgumentError, "foo", function():void { throw new ArgumentError("foo"); } );
|
11
|
+
}
|
12
|
+
|
13
|
+
[Test]
|
14
|
+
public function throwingUnexpectedErrorShouldFail():void {
|
15
|
+
try {
|
16
|
+
assertThrowsWithMessage(ArgumentError, "wrong error type", function():void { throw new Error("wrong error type"); } );
|
17
|
+
}
|
18
|
+
catch (e:AssertionFailedError) {
|
19
|
+
assertEquals("expected error type:<ArgumentError> but was:<Error>", e.message)
|
20
|
+
return;
|
21
|
+
}
|
22
|
+
fail('failed assertThrowsWithMessage() should have thrown AssertionFailedError');
|
23
|
+
}
|
24
|
+
|
25
|
+
[Test]
|
26
|
+
public function throwingNoErrorShouldFailWithMessage():void {
|
27
|
+
try {
|
28
|
+
assertThrowsWithMessage(ArgumentError, "foo", function():void { } );
|
29
|
+
}
|
30
|
+
catch (e:AssertionFailedError) {
|
31
|
+
assertEquals("expected error type:<ArgumentError> with message:<foo> but none was thrown.", e.message)
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
fail('failed assertThrowsWithMessage() should have thrown AssertionFailedError');
|
35
|
+
}
|
36
|
+
|
37
|
+
[Test]
|
38
|
+
public function throwingErrorWithUnexpectedMessageShouldFail():void {
|
39
|
+
try {
|
40
|
+
assertThrowsWithMessage(Error, "foo", function():void { throw new Error("bar"); } );
|
41
|
+
}
|
42
|
+
catch (e:AssertionFailedError) {
|
43
|
+
assertEquals("expected error message:<foo> but was:<bar>", e.message)
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
fail('failed assertThrowsWithMessage() should have thrown AssertionFailedError');
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
@@ -7,7 +7,6 @@
|
|
7
7
|
import asunit.framework.TestCase;
|
8
8
|
|
9
9
|
import flash.events.Event;
|
10
|
-
import flash.events.EventDispatcher;
|
11
10
|
import flash.utils.setTimeout;
|
12
11
|
|
13
12
|
public class AsyncTest {
|
@@ -15,9 +14,6 @@
|
|
15
14
|
[Inject]
|
16
15
|
public var async:IAsync;
|
17
16
|
|
18
|
-
[Inject]
|
19
|
-
public var dispatcher:EventDispatcher;
|
20
|
-
|
21
17
|
private var orphanAsync:IAsync;
|
22
18
|
private var command:TimeoutCommand;
|
23
19
|
|
@@ -15,8 +15,6 @@ package asunit.framework {
|
|
15
15
|
|
16
16
|
[Inject]
|
17
17
|
public var async:IAsync;
|
18
|
-
|
19
|
-
[Inject]
|
20
18
|
public var dispatcher:EventDispatcher;
|
21
19
|
|
22
20
|
private var orphanAsync:IAsync;
|
@@ -26,6 +24,7 @@ package asunit.framework {
|
|
26
24
|
[Before]
|
27
25
|
public function setUp():void {
|
28
26
|
orphanAsync = new Async();
|
27
|
+
dispatcher = new EventDispatcher();
|
29
28
|
}
|
30
29
|
|
31
30
|
[After]
|
@@ -0,0 +1,61 @@
|
|
1
|
+
package asunit.framework {
|
2
|
+
|
3
|
+
import asunit.asserts.*;
|
4
|
+
import asunit.support.FakeObserver;
|
5
|
+
import asunit.framework.Result;
|
6
|
+
|
7
|
+
public class ResultObserverTest {
|
8
|
+
|
9
|
+
private var result:Result;
|
10
|
+
|
11
|
+
private var listener:FakeObserver;
|
12
|
+
|
13
|
+
[Before]
|
14
|
+
public function createObserver():void {
|
15
|
+
listener = new FakeObserver();
|
16
|
+
result = new Result();
|
17
|
+
result.addListener(listener);
|
18
|
+
}
|
19
|
+
|
20
|
+
[After]
|
21
|
+
public function destroyObserver():void {
|
22
|
+
listener = null;
|
23
|
+
}
|
24
|
+
|
25
|
+
[Test]
|
26
|
+
public function canInstantiate():void {
|
27
|
+
assertTrue("instance is Result", result is Result);
|
28
|
+
}
|
29
|
+
|
30
|
+
[Test]
|
31
|
+
public function addedListenerReceivesOnRunStarted():void {
|
32
|
+
result.onRunStarted();
|
33
|
+
assertTrue(listener.onRunStartedCalled);
|
34
|
+
}
|
35
|
+
|
36
|
+
[Test]
|
37
|
+
public function addedListenerReceivesOnTestStarted():void {
|
38
|
+
result.onTestStarted(null);
|
39
|
+
assertTrue(listener.onTestStartedCalled);
|
40
|
+
}
|
41
|
+
|
42
|
+
[Test]
|
43
|
+
public function shouldHaveDefaultRunCount():void
|
44
|
+
{
|
45
|
+
assertEquals(0, result.runCount);
|
46
|
+
}
|
47
|
+
|
48
|
+
[Test]
|
49
|
+
public function shouldHaveCumulativeRunCount():void
|
50
|
+
{
|
51
|
+
result.onTestStarted(null);
|
52
|
+
result.onTestSuccess(null);
|
53
|
+
result.onTestCompleted(null);
|
54
|
+
result.onTestStarted(null);
|
55
|
+
result.onTestSuccess(null);
|
56
|
+
result.onTestCompleted(null);
|
57
|
+
assertEquals(2, result.runCount);
|
58
|
+
}
|
59
|
+
|
60
|
+
}
|
61
|
+
}
|
@@ -14,9 +14,13 @@ package asunit.framework {
|
|
14
14
|
|
15
15
|
public class RunnerFactoryTest {
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
private var factory:IRunnerFactory;
|
18
|
+
|
19
|
+
[Before]
|
20
|
+
public function before():void {
|
21
|
+
factory = new RunnerFactory();
|
22
|
+
}
|
23
|
+
|
20
24
|
[Test]
|
21
25
|
public function shouldCreateDefaultRunner():void {
|
22
26
|
var result:IRunner = factory.runnerFor(SucceedAssertTrue);
|
@@ -29,12 +33,6 @@ package asunit.framework {
|
|
29
33
|
assertTrue(result is SuiteRunner);
|
30
34
|
}
|
31
35
|
|
32
|
-
[Test]
|
33
|
-
public function shouldAssignFactoryOnCreation():void {
|
34
|
-
var result:IRunner = factory.runnerFor(SingleSuccessSuite);
|
35
|
-
assertSame(factory, result.factory);
|
36
|
-
}
|
37
|
-
|
38
36
|
[Test(expects="asunit.errors.UsageError")]
|
39
37
|
public function shouldFailWhenGivenANonTestOrSuite():void {
|
40
38
|
factory.runnerFor(Sprite);
|
@@ -7,37 +7,13 @@ package asunit.framework {
|
|
7
7
|
public class VisualTestCaseTest {
|
8
8
|
|
9
9
|
[Inject]
|
10
|
-
public var
|
10
|
+
public var context:Sprite;
|
11
11
|
|
12
12
|
[Test]
|
13
13
|
public function instantiated():void {
|
14
|
-
assertTrue(
|
15
|
-
}
|
16
|
-
|
17
|
-
[Test]
|
18
|
-
public function testSize():void {
|
19
|
-
assertTrue(sprite.width == 0);
|
20
|
-
assertTrue(sprite.height == 0);
|
14
|
+
assertTrue(context is Sprite);
|
21
15
|
}
|
22
16
|
|
23
|
-
[Test]
|
24
|
-
public function testDrawnSize():void {
|
25
|
-
sprite.x = 110;
|
26
|
-
sprite.y = 115;
|
27
|
-
sprite.graphics.beginFill(0xFF0000);
|
28
|
-
sprite.graphics.drawRect(0, 0, 100, 200);
|
29
|
-
|
30
|
-
assertEquals(100, sprite.width);
|
31
|
-
assertEquals(200, sprite.height);
|
32
|
-
assertEquals(110, sprite.x);
|
33
|
-
assertEquals(115, sprite.y);
|
34
|
-
}
|
35
|
-
|
36
|
-
[Test]
|
37
|
-
public function testSecondSize():void {
|
38
|
-
assertTrue(sprite.width == 0);
|
39
|
-
assertTrue(sprite.height == 0);
|
40
|
-
}
|
41
17
|
}
|
42
18
|
}
|
43
19
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
package asunit.printers {
|
3
|
+
|
4
|
+
import asunit.asserts.*;
|
5
|
+
import asunit.framework.TestCase;
|
6
|
+
|
7
|
+
public class FlashBuilderPrinterTest extends TestCase {
|
8
|
+
|
9
|
+
public function FlashBuilderPrinterTest(method:String=null) {
|
10
|
+
super(method);
|
11
|
+
}
|
12
|
+
|
13
|
+
private function testInstantiable():void {
|
14
|
+
var printer:FlashBuilderPrinter = new FlashBuilderPrinter();
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|