test/asunit/core/AsUnitCoreTest.as in asunit4-4.2.2.pre vs test/asunit/core/AsUnitCoreTest.as in asunit4-4.2.3.pre

- old
+ new

@@ -1,14 +1,13 @@ package asunit.core { import asunit.asserts.*; - import asunit.framework.CallbackBridge; import asunit.framework.IAsync; import asunit.framework.IResult; import asunit.framework.Result; import asunit.printers.TextPrinter; - import asunit.support.CustomTestRunner; + import asunit.support.CustomSuiteRunner; import asunit.support.SuiteWithCustomRunner; import asunit.support.SuiteWithOneCustomChildSuite; import asunit.support.SucceedAssertTrue; import flash.display.Sprite; @@ -17,19 +16,20 @@ public class AsUnitCoreTest { [Inject] public var async:IAsync; - [Inject] - public var core:AsUnitCore; + private var core:AsUnitCore; - [Inject] - public var context:Sprite; + [Before] + public function setUp():void { + core = new AsUnitCore(); + } [After] public function cleanUpStatics():void { - CustomTestRunner.runCalledCount = 0; + CustomSuiteRunner.runCalledCount = 0; } [Test] public function shouldBeInstantiated():void { assertTrue("core is AsUnitCore", core is AsUnitCore); @@ -37,22 +37,40 @@ [Test] public function startShouldWork():void { core.start(SucceedAssertTrue); } + + [Test] + public function shouldDispatchSelfAsCurrentTarget():void { + var handlerCalled:Boolean = false; + var handler:Function = function(event:Event):void { + assertSame("currentTarget should be the core", core, event.currentTarget); + handlerCalled = true; + core.removeEventListener(event.type, arguments.callee); + } + var eventType:String = "foo"; + core.addEventListener(eventType, handler); + // when + core.dispatchEvent(new Event(eventType)); + // then + assertTrue("handler called", handlerCalled); + } + [Test] public function setVisualContextShouldWork():void { + var context:Sprite = new Sprite(); core.visualContext = context; - assertEquals(context, core.visualContext); + assertSame(context, core.visualContext); } [Test] public function textPrinterShouldWork():void { var printer:TextPrinter = new TextPrinter(); printer.traceOnComplete = false; - core.addObserver(printer); + core.addListener(printer); // Wait for the complete event: var handler:Function = function(event:Event):void { var output:String = printer.toString(); assertTrue("should include test summary", output.indexOf('OK (1 test)') > -1); @@ -64,24 +82,24 @@ } private function verifyRunWithOnASuite(Suite:Class, testCaseCount:int, testMethodCount:int):void { var handler:Function = function(event:Event):void { - var message:String = "CustomRunner.run was NOT called with correct count"; + var message:String = "CustomSuiteRunner.run was NOT called with correct count"; // This is the number of Tests that will used the custom Runner: - assertEquals(message, testCaseCount, CustomTestRunner.runCalledCount); + assertEquals(message, testCaseCount, CustomSuiteRunner.runCalledCount); // This is the number of test methods: - assertEquals("Total Test Count", testMethodCount, core.bridge.runCount); + assertEquals("Total Test Count", testMethodCount, core.result.runCount); } core.addEventListener(Event.COMPLETE, async.add(handler, 200)); core.start(Suite); } [Test] - public function shouldAssignRunWithUsingOuterSuite():void { - // This will work b/c the RunWith is on the outer Suite: - var testCaseCount:int = 2; + public function shouldUseRunWithOnlyOnItsSuiteNotChildren():void { + // TheRunWith is on the outer Suite: + var testCaseCount:int = 1; var testMethodCount:int = 4; verifyRunWithOnASuite(SuiteWithCustomRunner, testCaseCount, testMethodCount); } [Ignore(description="This doesn't work because we discard the hierarchy of Suites in the SuiteIterator")]