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,21 +0,0 @@
|
|
1
|
-
package asunit.framework {
|
2
|
-
|
3
|
-
public interface ITestResult {
|
4
|
-
|
5
|
-
function addFailure(failure:ITestFailure):void;
|
6
|
-
|
7
|
-
function get errors():Array;
|
8
|
-
function get errorCount():uint;
|
9
|
-
|
10
|
-
function get failures():Array;
|
11
|
-
function get failureCount():uint;
|
12
|
-
|
13
|
-
function get runCount():uint;
|
14
|
-
function set runCount(value:uint):void;
|
15
|
-
|
16
|
-
function get wasSuccessful():Boolean;
|
17
|
-
|
18
|
-
function addListener(listener:ITestListener):void;
|
19
|
-
function removeListener(listener:ITestListener):void;
|
20
|
-
}
|
21
|
-
}
|
@@ -1,96 +0,0 @@
|
|
1
|
-
package asunit.framework {
|
2
|
-
|
3
|
-
import p2.reflect.ReflectionMetaData;
|
4
|
-
import p2.reflect.Reflection;
|
5
|
-
|
6
|
-
import flash.utils.Dictionary;
|
7
|
-
import asunit.errors.UsageError;
|
8
|
-
import p2.reflect.ReflectionVariable;
|
9
|
-
import p2.reflect.ReflectionMember;
|
10
|
-
import flash.utils.getDefinitionByName;
|
11
|
-
|
12
|
-
public class InjectionDelegate {
|
13
|
-
//---------------------------------------
|
14
|
-
// CLASS CONSTANTS
|
15
|
-
//---------------------------------------
|
16
|
-
|
17
|
-
public static const THROW_ERROR_ON_MISSING_INJECTION_POINT:Boolean = true;
|
18
|
-
public static const INJECT_ANNOTATION:String = "Inject";
|
19
|
-
|
20
|
-
private var entities:Dictionary;
|
21
|
-
|
22
|
-
public function InjectionDelegate()
|
23
|
-
{
|
24
|
-
entities = new Dictionary();
|
25
|
-
}
|
26
|
-
|
27
|
-
/**
|
28
|
-
* @param addict * an entity with at least one [Inject] annotation
|
29
|
-
*/
|
30
|
-
public function updateInjectionPoints(addict:*, throwErrorOnMissingInjection:Boolean=false):void {
|
31
|
-
var reflection:Reflection = Reflection.create(addict);
|
32
|
-
var members:Array = reflection.getMembersByMetaData(INJECT_ANNOTATION);
|
33
|
-
var addictName:String = reflection.name
|
34
|
-
if (throwErrorOnMissingInjection)
|
35
|
-
{
|
36
|
-
validateMembers(members, addictName);
|
37
|
-
}
|
38
|
-
var reflectionVariable:ReflectionVariable;
|
39
|
-
var injectionPointFound:Boolean;
|
40
|
-
members.forEach(function(member:ReflectionMember, index:int, items:Array):void {
|
41
|
-
reflectionVariable = member as ReflectionVariable;
|
42
|
-
if (reflectionVariable)
|
43
|
-
{
|
44
|
-
updateInjectionPoint(addict, reflectionVariable);
|
45
|
-
injectionPointFound = true;
|
46
|
-
}
|
47
|
-
});
|
48
|
-
|
49
|
-
if (!injectionPointFound && throwErrorOnMissingInjection)
|
50
|
-
{
|
51
|
-
throw new UsageError("InjectionDelegate expected at least one [Inject] annotation on a variable or accessor on" + addictName);
|
52
|
-
}
|
53
|
-
|
54
|
-
}
|
55
|
-
|
56
|
-
/**
|
57
|
-
* For each inject annotation we call this method
|
58
|
-
* @private
|
59
|
-
* @return
|
60
|
-
*/
|
61
|
-
private function updateInjectionPoint(addict:*, member:ReflectionVariable):void {
|
62
|
-
//FIXME: This actually could be a getter. If someone has their head up their booty.
|
63
|
-
var instance:* = getInstanceFromTypeName(member.type);
|
64
|
-
addict[member.name] = instance;
|
65
|
-
}
|
66
|
-
|
67
|
-
private function getInstanceFromTypeName(name:String):* {
|
68
|
-
var clazz:Class = getDefinitionByName(name) as Class;
|
69
|
-
return getOrCacheInstanceFromClass(clazz);
|
70
|
-
}
|
71
|
-
|
72
|
-
private function getOrCacheInstanceFromClass(clazz:Class):* {
|
73
|
-
if (!entities[clazz])
|
74
|
-
{
|
75
|
-
//FIXME: This will choke if given a class with constructor arguments!
|
76
|
-
entities[clazz] = new clazz();
|
77
|
-
updateInjectionPoints(entities[clazz]);
|
78
|
-
}
|
79
|
-
|
80
|
-
return entities[clazz];
|
81
|
-
}
|
82
|
-
|
83
|
-
/**
|
84
|
-
* @private
|
85
|
-
*/
|
86
|
-
private function validateMembers(members:Array, name:String):void
|
87
|
-
{
|
88
|
-
if (!members || members.length == 0)
|
89
|
-
{
|
90
|
-
throw new UsageError("InjectionDelegate expects at least one [Inject] annotation on " + name);
|
91
|
-
}
|
92
|
-
|
93
|
-
}
|
94
|
-
|
95
|
-
}
|
96
|
-
}
|
@@ -1,24 +0,0 @@
|
|
1
|
-
package asunit.framework {
|
2
|
-
|
3
|
-
/**
|
4
|
-
* MessageBridge is a marker interface that is used
|
5
|
-
* by AsUnit core in order to support custom messaging
|
6
|
-
* schemes between TestObservers and IRunners.
|
7
|
-
*
|
8
|
-
* The idea is that you [Inject] one or more entities
|
9
|
-
* into your concrete IRunner and related TestObservers.
|
10
|
-
*
|
11
|
-
* The contract is between the concrete MessageBridge,
|
12
|
-
* and the other actors that [Inject] it into.
|
13
|
-
*
|
14
|
-
* This implementation gives AsUnit the ability to support
|
15
|
-
* a variety of messaging protocols including native
|
16
|
-
* Flash EventDispatchers, callbacks, and even progressive
|
17
|
-
* systems like AS3Signals. The decision as to which
|
18
|
-
* messaging system to use is made by the person creating
|
19
|
-
* the concrete Runner and Observer.
|
20
|
-
*/
|
21
|
-
public interface MessageBridge {
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
@@ -1,12 +0,0 @@
|
|
1
|
-
package asunit.framework {
|
2
|
-
|
3
|
-
/**
|
4
|
-
* TestObserver is a marker interface that usually
|
5
|
-
* indicates that a given class will have at least
|
6
|
-
* one [Inject] annotation above a public instance
|
7
|
-
* variable that implements MessageBridge.
|
8
|
-
*/
|
9
|
-
public interface TestObserver {
|
10
|
-
}
|
11
|
-
}
|
12
|
-
|
@@ -1,73 +0,0 @@
|
|
1
|
-
package asunit.framework {
|
2
|
-
|
3
|
-
import asunit.asserts.*;
|
4
|
-
import asunit.support.FakeObserver;
|
5
|
-
import asunit.framework.Result;
|
6
|
-
import asunit.framework.CallbackBridge;
|
7
|
-
|
8
|
-
public class CallbackBridgeTest {
|
9
|
-
|
10
|
-
private var bridge:CallbackBridge;
|
11
|
-
|
12
|
-
private var observer:FakeObserver;
|
13
|
-
|
14
|
-
[Before]
|
15
|
-
public function createObserver():void {
|
16
|
-
observer = new FakeObserver();
|
17
|
-
bridge = new CallbackBridge();
|
18
|
-
bridge.addListener(observer);
|
19
|
-
}
|
20
|
-
|
21
|
-
[After]
|
22
|
-
public function destroyObserver():void {
|
23
|
-
observer = null;
|
24
|
-
}
|
25
|
-
|
26
|
-
[Test]
|
27
|
-
public function canInstantiate():void {
|
28
|
-
assertTrue("instance is CallbackBridge", bridge is CallbackBridge);
|
29
|
-
}
|
30
|
-
|
31
|
-
[Test]
|
32
|
-
public function addListenerWorked():void {
|
33
|
-
assertEquals(1, bridge.length);
|
34
|
-
}
|
35
|
-
|
36
|
-
[Test]
|
37
|
-
public function addedListenerReceivesOnRunStarted():void {
|
38
|
-
bridge.onRunStarted();
|
39
|
-
assertTrue(observer.onRunStartedCalled);
|
40
|
-
}
|
41
|
-
|
42
|
-
[Test]
|
43
|
-
public function addedListenerReceivesOnTestStarted():void {
|
44
|
-
bridge.onTestStarted(null);
|
45
|
-
assertTrue(observer.onTestStartedCalled);
|
46
|
-
}
|
47
|
-
|
48
|
-
[Test]
|
49
|
-
public function shouldHaveDefaultRunCount():void
|
50
|
-
{
|
51
|
-
assertEquals(0, bridge.runCount);
|
52
|
-
}
|
53
|
-
|
54
|
-
[Test]
|
55
|
-
public function shouldHaveCumulativeRunCount():void
|
56
|
-
{
|
57
|
-
/*
|
58
|
-
function onTestStarted(test:Object):void;
|
59
|
-
function onTestCompleted(test:Object):void;
|
60
|
-
function onTestFailure(failure:ITestFailure):void;
|
61
|
-
function onTestSuccess(success:ITestSuccess):void;
|
62
|
-
*/
|
63
|
-
bridge.onTestStarted(null);
|
64
|
-
bridge.onTestSuccess(null);
|
65
|
-
bridge.onTestCompleted(null);
|
66
|
-
bridge.onTestStarted(null);
|
67
|
-
bridge.onTestSuccess(null);
|
68
|
-
bridge.onTestCompleted(null);
|
69
|
-
assertEquals(2, bridge.runCount);
|
70
|
-
}
|
71
|
-
|
72
|
-
}
|
73
|
-
}
|
@@ -1,79 +0,0 @@
|
|
1
|
-
package asunit.framework {
|
2
|
-
|
3
|
-
import asunit.asserts.*;
|
4
|
-
|
5
|
-
public class InjectionDelegateTest {
|
6
|
-
|
7
|
-
[Inject]
|
8
|
-
public var injector:InjectionDelegate;
|
9
|
-
|
10
|
-
[Test]
|
11
|
-
public function testInstantiated():void {
|
12
|
-
assertTrue("instance is InjectionDelegate", injector is InjectionDelegate);
|
13
|
-
}
|
14
|
-
|
15
|
-
[Test]
|
16
|
-
public function testUpdateInjectionPoints():void {
|
17
|
-
var addict:Addict = new Addict();
|
18
|
-
injector.updateInjectionPoints(addict);
|
19
|
-
assertNotNull(addict.array);
|
20
|
-
}
|
21
|
-
|
22
|
-
[Test]
|
23
|
-
public function injectedInstancesShouldBeCached():void {
|
24
|
-
var addict:Addict = new Addict();
|
25
|
-
var addict2:Addict = new Addict();
|
26
|
-
|
27
|
-
injector.updateInjectionPoints(addict);
|
28
|
-
injector.updateInjectionPoints(addict2);
|
29
|
-
|
30
|
-
assertSame(addict.array, addict2.array);
|
31
|
-
|
32
|
-
}
|
33
|
-
|
34
|
-
[Test(expects="asunit.errors.UsageError")]
|
35
|
-
public function shouldThrowUsageErrorOnInvalidAddict():void
|
36
|
-
{
|
37
|
-
var invalidAddict:AddictWithNoInjections = new AddictWithNoInjections();
|
38
|
-
injector.updateInjectionPoints(invalidAddict, InjectionDelegate.THROW_ERROR_ON_MISSING_INJECTION_POINT);
|
39
|
-
}
|
40
|
-
|
41
|
-
[Test(expects="asunit.errors.UsageError")]
|
42
|
-
public function shouldThrowUsageErrorIfNoVariableInjectionsFound():void
|
43
|
-
{
|
44
|
-
var invalidAddict:AddictWithOnlyMethodInjection = new AddictWithOnlyMethodInjection();
|
45
|
-
injector.updateInjectionPoints(invalidAddict, InjectionDelegate.THROW_ERROR_ON_MISSING_INJECTION_POINT);
|
46
|
-
}
|
47
|
-
|
48
|
-
[Test]
|
49
|
-
public function shouldNotThrowUsageErrorOnInvalidAddict():void
|
50
|
-
{
|
51
|
-
var invalidAddict:AddictWithNoInjections = new AddictWithNoInjections();
|
52
|
-
injector.updateInjectionPoints(invalidAddict);
|
53
|
-
}
|
54
|
-
|
55
|
-
[Test]
|
56
|
-
public function shouldNotThrowUsageErrorIfNoVariableInjectionsFound():void
|
57
|
-
{
|
58
|
-
var invalidAddict:AddictWithOnlyMethodInjection = new AddictWithOnlyMethodInjection();
|
59
|
-
injector.updateInjectionPoints(invalidAddict);
|
60
|
-
}
|
61
|
-
|
62
|
-
}
|
63
|
-
}
|
64
|
-
|
65
|
-
//An addict that has no inject annotations
|
66
|
-
class AddictWithNoInjections {}
|
67
|
-
|
68
|
-
class AddictWithOnlyMethodInjection {
|
69
|
-
[Inject]
|
70
|
-
public function pleaseInjectMe(array:Array):void{};
|
71
|
-
}
|
72
|
-
|
73
|
-
class Addict {
|
74
|
-
[Inject]
|
75
|
-
public var array:Array;
|
76
|
-
|
77
|
-
[Inject]
|
78
|
-
public function pleaseInjectMe(array:Array):void{};
|
79
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
package asunit.support {
|
2
|
-
|
3
|
-
import asunit.asserts.*;
|
4
|
-
|
5
|
-
public class AnnotatedSubClass extends AnnotatedSuperClass {
|
6
|
-
|
7
|
-
[Test]
|
8
|
-
public function verifyDictionary():void {
|
9
|
-
assertNotNull(dictionary);
|
10
|
-
}
|
11
|
-
|
12
|
-
[Test]
|
13
|
-
public function verifyAsync():void {
|
14
|
-
assertNotNull(async);
|
15
|
-
}
|
16
|
-
}
|
17
|
-
}
|
18
|
-
|
@@ -1,15 +0,0 @@
|
|
1
|
-
package asunit.support {
|
2
|
-
|
3
|
-
import asunit.asserts.*;
|
4
|
-
import asunit.framework.IAsync;
|
5
|
-
import flash.utils.Dictionary;
|
6
|
-
|
7
|
-
public class AnnotatedSuperClass {
|
8
|
-
|
9
|
-
[Inject]
|
10
|
-
public var async:IAsync;
|
11
|
-
|
12
|
-
[Inject]
|
13
|
-
public var dictionary:Dictionary;
|
14
|
-
}
|
15
|
-
}
|
@@ -1,32 +0,0 @@
|
|
1
|
-
package asunit.support {
|
2
|
-
|
3
|
-
import asunit.framework.IRunner;
|
4
|
-
import asunit.framework.IResult;
|
5
|
-
import asunit.framework.TestSuccess;
|
6
|
-
import asunit.framework.IRunnerFactory;
|
7
|
-
|
8
|
-
import flash.events.EventDispatcher;
|
9
|
-
import flash.display.DisplayObjectContainer;
|
10
|
-
|
11
|
-
public class FakeRunner extends EventDispatcher implements IRunner {
|
12
|
-
|
13
|
-
public function run(testOrSuite:Class, result:IResult, testMethod:String=null, visualContext:DisplayObjectContainer=null):void {
|
14
|
-
var currentTest:TestForFakeRunner = new testOrSuite() as TestForFakeRunner;
|
15
|
-
|
16
|
-
result.onTestStarted(currentTest);
|
17
|
-
result.onTestSuccess(new TestSuccess(currentTest, 'customTestMethod'));
|
18
|
-
result.onTestCompleted(currentTest);
|
19
|
-
}
|
20
|
-
|
21
|
-
public function shouldRunTest(testClass:Class):Boolean {
|
22
|
-
return true;
|
23
|
-
}
|
24
|
-
|
25
|
-
public function set factory(factory:IRunnerFactory):void {
|
26
|
-
}
|
27
|
-
|
28
|
-
public function get factory():IRunnerFactory {
|
29
|
-
}
|
30
|
-
}
|
31
|
-
}
|
32
|
-
|
@@ -1,14 +0,0 @@
|
|
1
|
-
package asunit.support {
|
2
|
-
|
3
|
-
// Declare a fully-qualified runner for this test case:
|
4
|
-
[RunWith("asunit.support::FakeRunner")]
|
5
|
-
public class TestForFakeRunner {
|
6
|
-
|
7
|
-
private var runnerReference:FakeRunner;
|
8
|
-
|
9
|
-
public function customTestMethod():int {
|
10
|
-
throw new Error("This method shouldn't really get called");
|
11
|
-
}
|
12
|
-
}
|
13
|
-
}
|
14
|
-
|