-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed other versions of AsUnit to their own package names
- Loading branch information
Showing
168 changed files
with
4,389 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) <year> <copyright holders> | ||
|
||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
files (the "Software"), to deal in the Software without | ||
restriction, including without limitation the rights to use, | ||
copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
h1. AsUnit 3.x | ||
|
||
This build of the AsUnit test framework should support Flash Players 9, 10 and Adobe AIR. | ||
|
||
This framework includes runner base classes for ActionScript 3, Flex MXML or Adobe AIR test runners. | ||
|
||
|
||
|
52 changes: 52 additions & 0 deletions
52
asunit-3.0/examples/asunit/framework/AsynchronousTestMethodExample.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//Assume we have a feature that performs some asynchronous action: | ||
|
||
package net { | ||
|
||
import flash.events.Event; | ||
import flash.events.EventDispatcher; | ||
import flash.utils.setTimeout; | ||
|
||
[Event(name="complete", type="flash.events.Event")] | ||
public class AsyncMethod extends EventDispatcher { | ||
|
||
public function doSomething():void { | ||
setTimeout(function():void { | ||
dispatchEvent(new Event(Event.COMPLETE)); | ||
}, 100); | ||
} | ||
} | ||
} | ||
|
||
//We can test this feature with the following test case: | ||
package net { | ||
|
||
import asunit.framework.TestCase; | ||
import flash.events.Event; | ||
|
||
public class AsyncMethodTest extends TestCase { | ||
private var instance:AsyncMethod; | ||
|
||
public function AsyncMethodTest(methodName:String=null) { | ||
super(methodName) | ||
} | ||
|
||
override protected function setUp():void { | ||
super.setUp(); | ||
instance = new AsyncMethod(); | ||
} | ||
|
||
override protected function tearDown():void { | ||
super.tearDown(); | ||
instance = null; | ||
} | ||
|
||
public function testInstantiated():void { | ||
assertTrue("instance is AsyncMethod", instance is AsyncMethod); | ||
} | ||
|
||
public function testDoSomething():void { | ||
instance.addEventListener(Event.COMPLETE, addAsync()); | ||
instance.doSomething(); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
asunit-3.0/examples/asunit/framework/ComponentTestExample.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
And finally, the test case that will validate the ViewComponent class and | ||
it's goToHalfSize method. | ||
*/ | ||
|
||
package controls { | ||
|
||
import asunit.framework.TestCase; | ||
|
||
public class ViewComponentTest extends TestCase { | ||
private var instance:ViewComponent; | ||
|
||
public function ViewComponentTest(methodName:String=null) { | ||
super(methodName) | ||
} | ||
|
||
override protected function setUp():void { | ||
super.setUp(); | ||
instance = new ViewComponent(); | ||
addChild(instance); | ||
} | ||
|
||
override protected function tearDown():void { | ||
super.tearDown(); | ||
removeChild(instance); | ||
instance = null; | ||
} | ||
|
||
public function testInstantiated():void { | ||
assertTrue("instance is ViewComponent", instance is ViewComponent); | ||
} | ||
|
||
public function testGoToHalfSize():void { | ||
instance.width = 400; | ||
instance.height = 200; | ||
instance.goToHalfSize(); | ||
|
||
assertEquals('width', 200, instance.width); | ||
assertEquals('height', 100, instance.height); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
asunit-3.0/examples/asunit/framework/ComponentTestIntroduction.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
For the purpose of the following test example, we'll be using a Runner that | ||
looks like this: | ||
*/ | ||
|
||
package { | ||
import asunit.textui.TestRunner; | ||
import controls.ViewComponentTest; | ||
|
||
public class SomeProjectRunner extends TestRunner { | ||
|
||
public function SomeProjectRunner() { | ||
// start(clazz:Class, methodName:String, showTrace:Boolean) | ||
// NOTE: sending a particular class and method name will | ||
// execute setUp(), the method and NOT tearDown. | ||
// This allows you to get visual confirmation while developing | ||
// visual entities | ||
start(ViewComponentTest, 'testGoToHalfSize', TestRunner.SHOW_TRACE); | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
asunit-3.0/examples/asunit/framework/ComponentUnderTest.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
The following Component is a visual component whose primary feature | ||
is the 'goToHalfSize' method. | ||
*/ | ||
|
||
package controls { | ||
|
||
import flash.display.Sprite; | ||
import flash.events.Event; | ||
|
||
public class ViewComponent extends Sprite { | ||
|
||
private var _width:Number; | ||
private var _height:Number; | ||
|
||
public function ViewComponent() { | ||
_width = 640; | ||
_height = 480; | ||
} | ||
|
||
public function draw():void { | ||
graphics.clear(); | ||
graphics.beginFill(0xFFCC00); | ||
graphics.drawRect(0, 0, width, height); | ||
graphics.endFill(); | ||
} | ||
|
||
public function goToHalfSize():void { | ||
width = Math.round(width / 2); | ||
height = Math.round(height / 2); | ||
draw(); | ||
} | ||
|
||
override public function set width(width:Number):void { | ||
_width = width; | ||
} | ||
|
||
override public function get width():Number { | ||
return _width; | ||
} | ||
|
||
override public function set height(height:Number):void { | ||
_height = height; | ||
} | ||
|
||
override public function get height():Number { | ||
return _height; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package utils { | ||
|
||
public class MathUtil { | ||
|
||
public function MathUtil() { | ||
} | ||
|
||
public function addOne(num:Number):Number { | ||
return num + 1; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Assume we are testing a class that looks like this: | ||
package utils { | ||
|
||
public class MathUtil { | ||
|
||
// Add one to the number provided: | ||
public function addOne(num:Number):Number { | ||
return num + 1; | ||
} | ||
} | ||
} | ||
|
||
|
||
// This is a test case for the class above: | ||
package utils { | ||
|
||
import asunit.framework.TestCase; | ||
|
||
public class MathUtilTest extends TestCase { | ||
private var mathUtil:MathUtil; | ||
|
||
public function MathUtilTest(methodName:String=null) { | ||
super(methodName) | ||
} | ||
|
||
override protected function setUp():void { | ||
super.setUp(); | ||
mathUtil = new MathUtil(); | ||
} | ||
|
||
override protected function tearDown():void { | ||
super.tearDown(); | ||
mathUtil = null; | ||
} | ||
|
||
public function testInstantiated():void { | ||
assertTrue("mathUtil is MathUtil", mathUtil is MathUtil); | ||
} | ||
|
||
public function testAddOne():void { | ||
assertEquals(5, mathUtil.addOne(4)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package { | ||
import asunit.framework.TestSuite; | ||
import errors.CustomErrorTest; | ||
import net.CustomRequestTest; | ||
import net.CustomServiceTest; | ||
|
||
public class AllTests extends TestSuite { | ||
|
||
public function AllTests() { | ||
addTest(new errors.CustomErrorTest()); | ||
addTest(new net.CustomRequestTest()); | ||
addTest(new net.CustomServiceTest()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<AirRunner | ||
xmlns="asunit.textui.*" | ||
xmlns:mx="http://www.adobe.com/2006/mxml" | ||
creationComplete="runTests()" | ||
> | ||
<!-- Import Application Styles --> | ||
<mx:Style source="MyProjectSkin.css" /> | ||
<mx:Script> | ||
<![CDATA[ | ||
import asunit.textui.TestRunner; | ||
public function runTests():void { | ||
// start(clazz:Class, methodName:String, showTrace:Boolean) | ||
// NOTE: sending a particular class and method name will | ||
// execute setUp(), the method and NOT tearDown. | ||
// This allows you to get visual confirmation while developing | ||
// visual entities | ||
start(AllTests, null, TestRunner.SHOW_TRACE); | ||
} | ||
]]> | ||
</mx:Script> | ||
</AirRunner> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FlexRunner | ||
xmlns="asunit.textui.*" | ||
xmlns:mx="http://www.adobe.com/2006/mxml" | ||
creationComplete="runTests()" | ||
> | ||
<!-- Import Application Styles --> | ||
<mx:Style source="MyProjectSkin.css" /> | ||
<mx:Script> | ||
<![CDATA[ | ||
import asunit.textui.TestRunner; | ||
public function runTests():void { | ||
// start(clazz:Class, methodName:String, showTrace:Boolean) | ||
// NOTE: sending a particular class and method name will | ||
// execute setUp(), the method and NOT tearDown. | ||
// This allows you to get visual confirmation while developing | ||
// visual entities | ||
start(AllTests, null, TestRunner.SHOW_TRACE); | ||
} | ||
]]> | ||
</mx:Script> | ||
</FlexRunner> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package { | ||
import asunit.textui.TestRunner; | ||
|
||
public class SomeProjectRunner extends TestRunner { | ||
|
||
public function SomeProjectRunner() { | ||
// start(clazz:Class, methodName:String, showTrace:Boolean) | ||
// NOTE: sending a particular class and method name will | ||
// execute setUp(), the method and NOT tearDown. | ||
// This allows you to get visual confirmation while developing | ||
// visual entities | ||
start(AllTests, null, TestRunner.SHOW_TRACE); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
asunit-3.0/examples/asunit/textui/XMLResultPrinterExample.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package { | ||
import asunit.textui.TestRunner; | ||
import asunit.textui.XMLResultPrinter; | ||
|
||
public class XMLResultPrinterExample extends TestRunner { | ||
|
||
public function XMLResultPrinterExample() { | ||
// start(clazz:Class, methodName:String, showTrace:Boolean) | ||
// NOTE: sending a particular class and method name will | ||
// execute setUp(), the method and NOT tearDown. | ||
// This allows you to get visual confirmation while developing | ||
// visual entities | ||
setPrinter(new XMLResultPrinter()); | ||
start(AllTests, null, TestRunner.SHOW_TRACE); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
asunit-3.0/examples/asunit/textui/XMLResultPrinterExample.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<testsuites> | ||
<testsuite name="Flash Profile Card AsUnit Test Suite" errors="1" failures="1" tests="8" time="8.002"> | ||
<testcase classname="lib.test.cases.FailureTest" name="testError" time="0.049"> | ||
<error type="java.lang.NullPointerException"> | ||
<!-- stack trace --> | ||
</error> | ||
<failure type="Error">Reference runtime test error</failure> | ||
</testcase> | ||
<testcase classname="lib.test.cases.FailureTest" name="testAssertion"> | ||
<failure type="AssertionFailedError">Reference assertion test failure</failure> | ||
</testcase> | ||
</testsuite> | ||
</testsuites> |
Oops, something went wrong.