From commits-return-7991-archive-asf-public=cust-asf.ponee.io@royale.apache.org Thu Mar 14 20:22:56 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 00A98180630 for ; Thu, 14 Mar 2019 21:22:52 +0100 (CET) Received: (qmail 30785 invoked by uid 500); 14 Mar 2019 20:22:52 -0000 Mailing-List: contact commits-help@royale.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@royale.apache.org Delivered-To: mailing list commits@royale.apache.org Received: (qmail 30776 invoked by uid 99); 14 Mar 2019 20:22:52 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Mar 2019 20:22:52 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id ADD5F852BB; Thu, 14 Mar 2019 20:22:50 +0000 (UTC) Date: Thu, 14 Mar 2019 20:22:50 +0000 To: "commits@royale.apache.org" Subject: [royale-asjs] branch develop updated: RoyaleUnit MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <155259497058.16788.13397485767782134573@gitbox.apache.org> From: joshtynjala@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: royale-asjs X-Git-Refname: refs/heads/develop X-Git-Reftype: branch X-Git-Oldrev: a4db2333180b517295562715f3da82da8b5ca715 X-Git-Newrev: 757318461517889af48a9dede62a38fae69e164c X-Git-Rev: 757318461517889af48a9dede62a38fae69e164c X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. joshtynjala pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/royale-asjs.git The following commit(s) were added to refs/heads/develop by this push: new 7573184 RoyaleUnit 7573184 is described below commit 757318461517889af48a9dede62a38fae69e164c Author: Josh Tynjala AuthorDate: Thu Mar 14 13:22:44 2019 -0700 RoyaleUnit --- frameworks/build.xml | 19 +- .../projects/{TestingJS => RoyaleUnitJS}/build.xml | 4 +- .../src/main/config/compile-js-config.xml | 54 ++- frameworks/projects/Ace/build.xml | 2 +- frameworks/projects/Basic/build.xml | 2 +- .../royale/FlexUnitRoyaleApplication-config.xml | 16 +- .../src/test/royale/FlexUnitRoyaleApplication.mxml | 20 +- .../projects/Basic/src/test/royale/build.xml | 16 - .../royale/flexUnitTests/DataGridColumnTester.as | 2 +- frameworks/projects/Binding/build.xml | 2 +- frameworks/projects/Charts/build.xml | 2 +- frameworks/projects/Collections/build.xml | 2 +- .../royale/FlexUnitRoyaleApplication-config.xml | 16 +- .../src/test/royale/FlexUnitRoyaleApplication.mxml | 20 +- frameworks/projects/Core/src/test/royale/build.xml | 14 - .../src/test/royale/flexUnitTests/CoreTester.as | 2 +- frameworks/projects/CreateJS/build.xml | 2 +- frameworks/projects/DragDrop/build.xml | 2 +- frameworks/projects/Effects/build.xml | 2 +- frameworks/projects/Express/build.xml | 2 +- frameworks/projects/Flat/build.xml | 2 +- frameworks/projects/FontAwesome/build.xml | 2 +- frameworks/projects/Formatters/build.xml | 2 +- frameworks/projects/GoogleMaps/build.xml | 2 +- frameworks/projects/Graphics/build.xml | 2 +- frameworks/projects/HTML/build.xml | 4 +- .../flexUnitTests/DataGridColumnTesterTest.as | 55 --- frameworks/projects/HTML5/build.xml | 2 +- frameworks/projects/Icons/build.xml | 2 +- frameworks/projects/JQuery/build.xml | 2 +- frameworks/projects/Jewel/build.xml | 2 +- frameworks/projects/Language/build.xml | 2 +- frameworks/projects/MXRoyale/build.xml | 2 +- frameworks/projects/MaterialDesignLite/build.xml | 2 +- frameworks/projects/Mobile/build.xml | 2 +- frameworks/projects/Network/build.xml | 2 +- frameworks/projects/Reflection/build.xml | 2 +- frameworks/projects/RoyaleSite/build.xml | 2 +- .../asserts/fail.as => RoyaleUnit/asconfig.json} | 42 +-- .../projects/{Collections => RoyaleUnit}/build.xml | 7 +- .../projects/{Testing => RoyaleUnit}/pom.xml | 38 +- .../src/main/config/compile-swf-config.xml | 35 +- .../src/main/royale/RoyaleUnitClasses.as | 58 +++ .../main/royale/org/apache/royale/test/Assert.as | 205 +++++++++++ .../org/apache/royale/test/AssertionError.as} | 69 ++-- .../org/apache/royale/test/RoyaleUnitCore.as | 315 ++++++++++++++++ .../apache/royale/test/asserts/assertEquals.as} | 19 +- .../org/apache/royale/test/asserts/assertFalse.as} | 19 +- .../apache/royale/test/asserts/assertNotEquals.as} | 19 +- .../apache/royale/test/asserts/assertNotNull.as} | 19 +- .../test/asserts/assertNotStrictlyEquals.as} | 19 +- .../org/apache/royale/test/asserts/assertNull.as} | 19 +- .../royale/test/asserts/assertStrictlyEquals.as} | 19 +- .../org/apache/royale/test/asserts/assertTrue.as} | 19 +- .../royale/org/apache/royale/test/asserts/fail.as} | 19 +- .../org/apache/royale/test/listeners/CIListener.as | 397 +++++++++++++++++++++ .../royale/test/listeners/FailureListener.as | 92 +++++ .../apache/royale/test/listeners/TraceListener.as | 185 ++++++++++ .../org/apache/royale/test/runners/ITestRunner.as} | 31 +- .../apache/royale/test/runners/MetadataRunner.as | 256 +++++++++++++ .../org/apache/royale/test/runners/ParentRunner.as | 335 +++++++++++++++++ .../org/apache/royale/test/runners/SuiteRunner.as | 90 +++++ .../org/apache/royale/test/runners/TestMetadata.as | 67 ++++ .../royale/test/runners/notification/Failure.as | 84 +++++ .../notification/IAsyncStartupRunListener.as} | 32 +- .../test/runners/notification/IRunListener.as} | 74 ++-- .../test/runners/notification/IRunNotifier.as | 77 ++++ .../royale/test/runners/notification/Result.as | 177 +++++++++ .../test/runners/notification/RunNotifier.as | 171 +++++++++ .../royale/FlexUnitRoyaleApplication-config.xml | 29 +- .../src/test/royale/FlexUnitRoyaleApplication.mxml | 23 +- .../src/test/royale/NodeTests.as | 43 +-- .../RoyaleUnit/src/test/royale/asconfig.json | 35 ++ .../{HTML => RoyaleUnit}/src/test/royale/build.xml | 37 +- .../src/test/royale/tests/BeforeAndAfterTests.as | 172 +++++++++ .../royale/tests/BeforeClassAndAfterClassTests.as | 212 +++++++++++ .../src/test/royale/tests/IgnoreTests.as | 108 ++++++ .../src/test/royale/tests/RoyaleUnitSuite.as} | 19 +- .../src/test/royale/tests/ScopeTests.as | 8 +- frameworks/projects/SparkRoyale/build.xml | 2 +- frameworks/projects/Storage/build.xml | 2 +- frameworks/projects/TLF/build.xml | 2 +- frameworks/projects/Testing/asconfig.json | 21 -- frameworks/projects/Testing/build.xml | 160 --------- .../Testing/src/main/resources/basic-manifest.xml | 23 -- .../Testing/src/main/resources/defaults.css | 23 -- .../Testing/src/main/royale/TestingClasses.as | 46 --- .../main/royale/org/apache/royale/test/Assert.as | 156 -------- .../org/apache/royale/test/AssertionError.as | 32 -- .../royale/org/apache/royale/test/TestEvent.as | 58 --- .../royale/org/apache/royale/test/TestRunner.as | 354 ------------------ .../royale/org/apache/royale/test/TraceListener.as | 144 -------- .../apache/royale/test/asserts/assertDefined.as | 52 --- .../org/apache/royale/test/asserts/assertEquals.as | 53 --- .../org/apache/royale/test/asserts/assertFalse.as | 55 --- .../apache/royale/test/asserts/assertNotNull.as | 54 --- .../org/apache/royale/test/asserts/assertNull.as | 53 --- .../royale/test/asserts/assertStrictlyEquals.as | 54 --- .../org/apache/royale/test/asserts/assertTrue.as | 54 --- .../apache/royale/test/asserts/assertUndefined.as | 54 --- .../projects/Testing/src/test/royale/asconfig.json | 19 - .../projects/Testing/src/test/royale/build.xml | 165 --------- frameworks/projects/Text/build.xml | 2 +- frameworks/projects/XML/build.xml | 2 +- frameworks/projects/pom.xml | 2 +- frameworks/royale-config-template.xml | 4 +- 106 files changed, 3515 insertions(+), 2117 deletions(-) diff --git a/frameworks/build.xml b/frameworks/build.xml index 7538236..d0bcfa3 100644 --- a/frameworks/build.xml +++ b/frameworks/build.xml @@ -109,15 +109,16 @@ - + - + + @@ -170,7 +171,6 @@ - @@ -192,6 +192,7 @@ + @@ -230,10 +231,6 @@ - - - - @@ -330,6 +327,14 @@ + + + + + + + + diff --git a/frameworks/js/projects/TestingJS/build.xml b/frameworks/js/projects/RoyaleUnitJS/build.xml similarity index 97% rename from frameworks/js/projects/TestingJS/build.xml rename to frameworks/js/projects/RoyaleUnitJS/build.xml index 4467a63..82e5b33 100644 --- a/frameworks/js/projects/TestingJS/build.xml +++ b/frameworks/js/projects/RoyaleUnitJS/build.xml @@ -19,13 +19,13 @@ --> - + - + target.name.nojs=${ant.project.name} diff --git a/frameworks/js/projects/TestingJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/RoyaleUnitJS/src/main/config/compile-js-config.xml similarity index 62% rename from frameworks/js/projects/TestingJS/src/main/config/compile-js-config.xml rename to frameworks/js/projects/RoyaleUnitJS/src/main/config/compile-js-config.xml index 80f7289..82751a9 100644 --- a/frameworks/js/projects/TestingJS/src/main/config/compile-js-config.xml +++ b/frameworks/js/projects/RoyaleUnitJS/src/main/config/compile-js-config.xml @@ -28,15 +28,12 @@ true - - - - - true - - org.apache.royale.events.ValueChangeEvent - org.apache.royale.events.ValueChangeEvent - valueChange + + true + + org.apache.royale.events.ValueChangeEvent + org.apache.royale.events.ValueChangeEvent + valueChange COMPILE::SWF @@ -53,47 +50,38 @@ ChangeEvent NonCommittingChangeEvent Transient + + + Test + Before + After + BeforeClass + AfterClass + Ignore + Suite + RunWith - ../../../../../../../js/libs/GCL.swc + ../../../../../libs/LanguageJS.swc + ../../../../../libs/CoreJS.swc + ../../../../../libs/ReflectionJS.swc - - - library://ns.apache.org/royale/basic - ../../../../../../projects/Testing/src/main/resources/basic-manifest.xml - - - - ../../../../../../projects/Testing/src/main/royale + ../../../../../../projects/RoyaleUnit/src/main/royale false - - defaults.css - ../../../../../../projects/Testing/src/main/resources/defaults.css - - - - - - TestingClasses + RoyaleUnitClasses - - - library://ns.apache.org/royale/basic - - - diff --git a/frameworks/projects/Ace/build.xml b/frameworks/projects/Ace/build.xml index 1bc99ee..e85b1da 100644 --- a/frameworks/projects/Ace/build.xml +++ b/frameworks/projects/Ace/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/Basic/build.xml b/frameworks/projects/Basic/build.xml index d8ab079..531eefc 100644 --- a/frameworks/projects/Basic/build.xml +++ b/frameworks/projects/Basic/build.xml @@ -57,7 +57,7 @@ - + diff --git a/frameworks/projects/Basic/src/test/royale/FlexUnitRoyaleApplication-config.xml b/frameworks/projects/Basic/src/test/royale/FlexUnitRoyaleApplication-config.xml index 4b67e92..5d914d7 100644 --- a/frameworks/projects/Basic/src/test/royale/FlexUnitRoyaleApplication-config.xml +++ b/frameworks/projects/Basic/src/test/royale/FlexUnitRoyaleApplication-config.xml @@ -41,7 +41,8 @@ ../../../../../libs/Core.swc ../../../../../libs/Graphics.swc ../../../../../libs/Collections.swc - ../../../../../libs/Testing.swc + ../../../../../libs/Reflection.swc + ../../../../../libs/RoyaleUnit.swc @@ -50,7 +51,8 @@ ../../../../../js/libs/CoreJS.swc ../../../../../js/libs/GraphicsJS.swc ../../../../../js/libs/CollectionsJS.swc - ../../../../../js/libs/TestingJS.swc + ../../../../../js/libs/ReflectionJS.swc + ../../../../../js/libs/RoyaleUnitJS.swc true @@ -79,6 +81,16 @@ NonCommittingChangeEvent Transient SWFOverride + + + Test + Before + After + BeforeClass + AfterClass + Ignore + Suite + RunWith diff --git a/frameworks/projects/Basic/src/test/royale/FlexUnitRoyaleApplication.mxml b/frameworks/projects/Basic/src/test/royale/FlexUnitRoyaleApplication.mxml index e8f1b17..242765b 100644 --- a/frameworks/projects/Basic/src/test/royale/FlexUnitRoyaleApplication.mxml +++ b/frameworks/projects/Basic/src/test/royale/FlexUnitRoyaleApplication.mxml @@ -20,20 +20,30 @@ limitations under the License. + + + diff --git a/frameworks/projects/Basic/src/test/royale/build.xml b/frameworks/projects/Basic/src/test/royale/build.xml index 511167e..d452d24 100644 --- a/frameworks/projects/Basic/src/test/royale/build.xml +++ b/frameworks/projects/Basic/src/test/royale/build.xml @@ -48,18 +48,6 @@ property="FLEXUNIT_HOME" value="${env.FLEXUNIT_HOME}"/> - - - - - - - - @@ -118,8 +104,6 @@ - - diff --git a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as b/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as index 4b0ecfc..cda8504 100644 --- a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as +++ b/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as @@ -19,7 +19,7 @@ package flexUnitTests { [Suite] - [RunWith("org.flexunit.runners.Suite")] + [RunWith("org.apache.royale.test.runners.SuiteRunner")] public class DataGridColumnTester { public var dataGridColumnTest:DataGridColumnTest; diff --git a/frameworks/projects/Binding/build.xml b/frameworks/projects/Binding/build.xml index dff2379..842dd99 100644 --- a/frameworks/projects/Binding/build.xml +++ b/frameworks/projects/Binding/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/Charts/build.xml b/frameworks/projects/Charts/build.xml index 41d0aa6..80f46f6 100644 --- a/frameworks/projects/Charts/build.xml +++ b/frameworks/projects/Charts/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/Collections/build.xml b/frameworks/projects/Collections/build.xml index 0af95f7..3de5f29 100644 --- a/frameworks/projects/Collections/build.xml +++ b/frameworks/projects/Collections/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/Core/src/test/royale/FlexUnitRoyaleApplication-config.xml b/frameworks/projects/Core/src/test/royale/FlexUnitRoyaleApplication-config.xml index 7063b81..6eeb8d5 100644 --- a/frameworks/projects/Core/src/test/royale/FlexUnitRoyaleApplication-config.xml +++ b/frameworks/projects/Core/src/test/royale/FlexUnitRoyaleApplication-config.xml @@ -41,7 +41,8 @@ ../../../../../libs/Core.swc ../../../../../libs/Graphics.swc ../../../../../libs/Collections.swc - ../../../../../libs/Testing.swc + ../../../../../libs/Reflection.swc + ../../../../../libs/RoyaleUnit.swc @@ -50,7 +51,8 @@ ../../../../../js/libs/CoreJS.swc ../../../../../js/libs/GraphicsJS.swc ../../../../../js/libs/CollectionsJS.swc - ../../../../../js/libs/TestingJS.swc + ../../../../../js/libs/ReflectionJS.swc + ../../../../../js/libs/RoyaleUnitJS.swc true @@ -79,6 +81,16 @@ NonCommittingChangeEvent Transient SWFOverride + + + Test + Before + After + BeforeClass + AfterClass + Ignore + Suite + RunWith diff --git a/frameworks/projects/Core/src/test/royale/FlexUnitRoyaleApplication.mxml b/frameworks/projects/Core/src/test/royale/FlexUnitRoyaleApplication.mxml index dd519f3..604c550 100644 --- a/frameworks/projects/Core/src/test/royale/FlexUnitRoyaleApplication.mxml +++ b/frameworks/projects/Core/src/test/royale/FlexUnitRoyaleApplication.mxml @@ -20,22 +20,30 @@ limitations under the License. + + + diff --git a/frameworks/projects/Core/src/test/royale/build.xml b/frameworks/projects/Core/src/test/royale/build.xml index e920264..a90a105 100644 --- a/frameworks/projects/Core/src/test/royale/build.xml +++ b/frameworks/projects/Core/src/test/royale/build.xml @@ -48,18 +48,6 @@ property="FLEXUNIT_HOME" value="${env.FLEXUNIT_HOME}"/> - - - - - - - - diff --git a/frameworks/projects/Core/src/test/royale/flexUnitTests/CoreTester.as b/frameworks/projects/Core/src/test/royale/flexUnitTests/CoreTester.as index 2f99400..42ba4fa 100644 --- a/frameworks/projects/Core/src/test/royale/flexUnitTests/CoreTester.as +++ b/frameworks/projects/Core/src/test/royale/flexUnitTests/CoreTester.as @@ -19,7 +19,7 @@ package flexUnitTests { [Suite] - [RunWith("org.flexunit.runners.Suite")] + [RunWith("org.apache.royale.test.runners.SuiteRunner")] public class CoreTester { public var strandTesterTest:StrandTesterTest; diff --git a/frameworks/projects/CreateJS/build.xml b/frameworks/projects/CreateJS/build.xml index 03a0062..e71f051 100644 --- a/frameworks/projects/CreateJS/build.xml +++ b/frameworks/projects/CreateJS/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/DragDrop/build.xml b/frameworks/projects/DragDrop/build.xml index 5a3e854..32c6240 100644 --- a/frameworks/projects/DragDrop/build.xml +++ b/frameworks/projects/DragDrop/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/Effects/build.xml b/frameworks/projects/Effects/build.xml index 6852ae1..35c9795 100644 --- a/frameworks/projects/Effects/build.xml +++ b/frameworks/projects/Effects/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/Express/build.xml b/frameworks/projects/Express/build.xml index bea2234..2bde63f 100644 --- a/frameworks/projects/Express/build.xml +++ b/frameworks/projects/Express/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/Flat/build.xml b/frameworks/projects/Flat/build.xml index cd1ec96..095e28a 100644 --- a/frameworks/projects/Flat/build.xml +++ b/frameworks/projects/Flat/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/FontAwesome/build.xml b/frameworks/projects/FontAwesome/build.xml index c37d76b..f92e342 100644 --- a/frameworks/projects/FontAwesome/build.xml +++ b/frameworks/projects/FontAwesome/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/Formatters/build.xml b/frameworks/projects/Formatters/build.xml index d587995..61a193a 100644 --- a/frameworks/projects/Formatters/build.xml +++ b/frameworks/projects/Formatters/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/GoogleMaps/build.xml b/frameworks/projects/GoogleMaps/build.xml index cea0583..cb8b10d 100644 --- a/frameworks/projects/GoogleMaps/build.xml +++ b/frameworks/projects/GoogleMaps/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/Graphics/build.xml b/frameworks/projects/Graphics/build.xml index 6745675..0ec9eae 100644 --- a/frameworks/projects/Graphics/build.xml +++ b/frameworks/projects/Graphics/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/HTML/build.xml b/frameworks/projects/HTML/build.xml index 1b395cf..8a2de5c 100644 --- a/frameworks/projects/HTML/build.xml +++ b/frameworks/projects/HTML/build.xml @@ -52,8 +52,8 @@ - - + + diff --git a/frameworks/projects/HTML/src/test/royale/flexUnitTests/DataGridColumnTesterTest.as b/frameworks/projects/HTML/src/test/royale/flexUnitTests/DataGridColumnTesterTest.as deleted file mode 100644 index d73b572..0000000 --- a/frameworks/projects/HTML/src/test/royale/flexUnitTests/DataGridColumnTesterTest.as +++ /dev/null @@ -1,55 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package flexUnitTests -{ - import flexunit.framework.Assert; - - import org.apache.royale.html.supportClasses.DataGridColumn; - - public class DataGridColumnTesterTest - { - [Before] - public function setUp():void - { - } - - [After] - public function tearDown():void - { - } - - [BeforeClass] - public static function setUpBeforeClass():void - { - } - - [AfterClass] - public static function tearDownAfterClass():void - { - } - - [Test] - public function testLabelProperty():void - { - var column:DataGridColumn = new DataGridColumn(); - column.label = "foo"; - Assert.assertEquals("Error testing DataGridColumn.label", column.label, "foo"); - } - } -} diff --git a/frameworks/projects/HTML5/build.xml b/frameworks/projects/HTML5/build.xml index 106a1e6..a5ac033 100644 --- a/frameworks/projects/HTML5/build.xml +++ b/frameworks/projects/HTML5/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/Icons/build.xml b/frameworks/projects/Icons/build.xml index d940bfc..5ab4307 100644 --- a/frameworks/projects/Icons/build.xml +++ b/frameworks/projects/Icons/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/JQuery/build.xml b/frameworks/projects/JQuery/build.xml index 0c2f3b8..d683562 100644 --- a/frameworks/projects/JQuery/build.xml +++ b/frameworks/projects/JQuery/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/Jewel/build.xml b/frameworks/projects/Jewel/build.xml index dba5aaa..6490239 100644 --- a/frameworks/projects/Jewel/build.xml +++ b/frameworks/projects/Jewel/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/Language/build.xml b/frameworks/projects/Language/build.xml index 21105e4..3a08219 100644 --- a/frameworks/projects/Language/build.xml +++ b/frameworks/projects/Language/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/MXRoyale/build.xml b/frameworks/projects/MXRoyale/build.xml index 2a6228a..873c0ca 100644 --- a/frameworks/projects/MXRoyale/build.xml +++ b/frameworks/projects/MXRoyale/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/MaterialDesignLite/build.xml b/frameworks/projects/MaterialDesignLite/build.xml index 1adbe06..2d8ff20 100644 --- a/frameworks/projects/MaterialDesignLite/build.xml +++ b/frameworks/projects/MaterialDesignLite/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/Mobile/build.xml b/frameworks/projects/Mobile/build.xml index c7e3c82..5a00257 100644 --- a/frameworks/projects/Mobile/build.xml +++ b/frameworks/projects/Mobile/build.xml @@ -54,7 +54,7 @@ - + diff --git a/frameworks/projects/Network/build.xml b/frameworks/projects/Network/build.xml index 00dae73..9e444fd 100644 --- a/frameworks/projects/Network/build.xml +++ b/frameworks/projects/Network/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/Reflection/build.xml b/frameworks/projects/Reflection/build.xml index b91e1a5..1103d1e 100644 --- a/frameworks/projects/Reflection/build.xml +++ b/frameworks/projects/Reflection/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/RoyaleSite/build.xml b/frameworks/projects/RoyaleSite/build.xml index c39dc70..8799179 100644 --- a/frameworks/projects/RoyaleSite/build.xml +++ b/frameworks/projects/RoyaleSite/build.xml @@ -54,7 +54,7 @@ - + diff --git a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/fail.as b/frameworks/projects/RoyaleUnit/asconfig.json similarity index 65% rename from frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/fail.as rename to frameworks/projects/RoyaleUnit/asconfig.json index e181386..79226fb 100644 --- a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/fail.as +++ b/frameworks/projects/RoyaleUnit/asconfig.json @@ -14,26 +14,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.royale.test.asserts { - - COMPILE::SWF - { - import org.flexunit.Assert; - } - - COMPILE::JS - { - import org.apache.royale.test.Assert; - } - - /** - * Fails a test with the given message. - * - * @param failMessage - * the identifying message for the AssertionFailedError - * @see AssertionFailedError - */ - public function fail( failMessage:String):void { - Assert.fail( failMessage ); - } -} \ No newline at end of file + { + "config": "royale", + "type": "lib", + "compilerOptions": { + "targets": [ + "SWF", + "JSRoyale" + ], + "source-path": [ + "src/main/royale", + "src/test/royale" + ], + "include-classes": [ + "RoyaleUnitClasses" + ], + "warn-public-vars": false, + "output": "target/RoyaleUnit.swc" + } +} diff --git a/frameworks/projects/Collections/build.xml b/frameworks/projects/RoyaleUnit/build.xml similarity index 95% copy from frameworks/projects/Collections/build.xml copy to frameworks/projects/RoyaleUnit/build.xml index 0af95f7..990da7e 100644 --- a/frameworks/projects/Collections/build.xml +++ b/frameworks/projects/RoyaleUnit/build.xml @@ -19,7 +19,7 @@ --> - + @@ -29,7 +29,8 @@ - + + @@ -52,7 +53,7 @@ - + diff --git a/frameworks/projects/Testing/pom.xml b/frameworks/projects/RoyaleUnit/pom.xml similarity index 65% rename from frameworks/projects/Testing/pom.xml rename to frameworks/projects/RoyaleUnit/pom.xml index 82f2449..6d7e8f1 100644 --- a/frameworks/projects/Testing/pom.xml +++ b/frameworks/projects/RoyaleUnit/pom.xml @@ -23,14 +23,14 @@ org.apache.royale.framework projects - 0.9.0-SNAPSHOT + 0.9.6-SNAPSHOT - Testing - 0.9.1-SNAPSHOT + RoyaleUnit + 0.9.6-SNAPSHOT swc - Apache Royale: Framework: Libs: Testing + Apache Royale: Framework: Libs: RoyaleUnit src/main/royale @@ -41,22 +41,9 @@ ${royale.compiler.version} true - - - library://ns.apache.org/royale/basic - ${project.basedir}/src/main/resources/basic-manifest.xml - - - - TestingClasses - - - - defaults.css - ../src/main/resources/defaults.css - - + true true + -source-map=true @@ -66,26 +53,17 @@ org.apache.royale.framework Core - 0.9.0-SNAPSHOT + 0.9.6-SNAPSHOT swc swf org.apache.royale.framework Core - 0.9.0-SNAPSHOT + 0.9.6-SNAPSHOT swc js - - - org.apache.royale.typedefs - royale-typedefs-cordova - ${royale.typedefs.version} - swc - typedefs - runtime - diff --git a/frameworks/projects/Testing/src/main/config/compile-swf-config.xml b/frameworks/projects/RoyaleUnit/src/main/config/compile-swf-config.xml similarity index 77% rename from frameworks/projects/Testing/src/main/config/compile-swf-config.xml rename to frameworks/projects/RoyaleUnit/src/main/config/compile-swf-config.xml index e1cfe72..0fd9180 100644 --- a/frameworks/projects/Testing/src/main/config/compile-swf-config.xml +++ b/frameworks/projects/RoyaleUnit/src/main/config/compile-swf-config.xml @@ -30,14 +30,20 @@ ${env.AIR_HOME}/frameworks/libs/air/airglobal.swc + ../../../../../libs/Language.swc + ../../../../../libs/Core.swc + ../../../../../libs/Reflection.swc + true + true org.apache.royale.events.ValueChangeEvent org.apache.royale.events.ValueChangeEvent valueChange + flash.display.Sprite COMPILE::SWF @@ -54,18 +60,22 @@ ChangeEvent NonCommittingChangeEvent Transient + SWFOverride + + + Test + Before + After + BeforeClass + AfterClass + Ignore + Suite + RunWith - - - - library://ns.apache.org/royale/basic - ../resources/basic-manifest.xml - - ../royale @@ -73,19 +83,10 @@ false - - - defaults.css - ../resources/defaults.css - - TestingClasses + RoyaleUnitClasses - - - library://ns.apache.org/royale/basic - ${playerglobal.version} diff --git a/frameworks/projects/RoyaleUnit/src/main/royale/RoyaleUnitClasses.as b/frameworks/projects/RoyaleUnit/src/main/royale/RoyaleUnitClasses.as new file mode 100644 index 0000000..0adebd1 --- /dev/null +++ b/frameworks/projects/RoyaleUnit/src/main/royale/RoyaleUnitClasses.as @@ -0,0 +1,58 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package +{ +/** + * @private + * This class is used to link additional classes into the swc + * beyond those that are found by dependency analysis starting + * from the classes specified in manifest.xml. + */ +internal class RoyaleUnitClasses +{ + import org.apache.royale.test.Assert;Assert; + import org.apache.royale.test.AssertionError;AssertionError; + import org.apache.royale.test.RoyaleUnitCore;RoyaleUnitCore; + import org.apache.royale.test.asserts.assertEquals;assertEquals; + import org.apache.royale.test.asserts.assertFalse;assertFalse; + import org.apache.royale.test.asserts.assertNotEquals;assertNotEquals; + import org.apache.royale.test.asserts.assertNotNull;assertNotNull; + import org.apache.royale.test.asserts.assertNotStrictlyEquals;assertNotStrictlyEquals; + import org.apache.royale.test.asserts.assertNull;assertNull; + import org.apache.royale.test.asserts.assertStrictlyEquals;assertStrictlyEquals; + import org.apache.royale.test.asserts.assertTrue;assertTrue; + import org.apache.royale.test.asserts.fail;fail; + import org.apache.royale.test.listeners.FailureListener;FailureListener; + import org.apache.royale.test.listeners.TraceListener;TraceListener + import org.apache.royale.test.runners.ITestRunner;ITestRunner; + import org.apache.royale.test.runners.MetadataRunner;MetadataRunner; + import org.apache.royale.test.runners.ParentRunner;ParentRunner; + import org.apache.royale.test.runners.SuiteRunner;SuiteRunner; + import org.apache.royale.test.runners.notification.Failure;Failure; + import org.apache.royale.test.runners.notification.IRunListener;IRunListener; + import org.apache.royale.test.runners.notification.IRunNotifier;IRunNotifier; + import org.apache.royale.test.runners.notification.Result;Result; + import org.apache.royale.test.runners.notification.RunNotifier;RunNotifier; + + COMPILE::SWF + { + import org.apache.royale.test.listeners.CIListener;CIListener; + } +} +} \ No newline at end of file diff --git a/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/Assert.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/Assert.as new file mode 100644 index 0000000..baa8929 --- /dev/null +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/Assert.as @@ -0,0 +1,205 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.royale.test +{ + /** + * A set of assertion methods. Messages only displayed when an assert fails. + */ + public class Assert + { + /** + * Asserts that the provided values are strictly equal (equivalent to + * the === operator). + */ + public static function assertStrictlyEquals(actual:*, expected:*, message:String = null):void + { + failNotStrictlyEquals(actual, expected, message); + } + + /** + * Asserts that the provided values are not strictly equal (equivalent + * to the !== operator). + */ + public static function assertNotStrictlyEquals(actual:*, expected:*, message:String = null):void + { + failStrictlyEquals(actual, expected, message); + } + + /** + * Asserts that the provided values are loosely equal (equivalent to + * the == operator). + */ + public static function assertEquals(actual:*, expected:*, message:String = null):void + { + failNotEquals(actual, expected, message); + } + + /** + * Asserts that the provided values are not loosely equal (equivalent to + * the != operator). + */ + public static function assertNotEquals(actual:*, expected:*, message:String = null):void + { + failEquals(actual, expected, message); + } + + /** + * Asserts that the provided value is true (equivalent to testing the + * value in an if(value) statement). + */ + public static function assertTrue(value:*, message:String = null):void + { + failFalse(value, message); + } + + /** + * Asserts that the provided value is true (equivalent to testing the + * value in an if(!value) statement). + */ + public static function assertFalse(value:*, message:String = null):void + { + failTrue(value, message); + } + + /** + * Asserts that the provided value is null. + */ + public static function assertNull(actual:*, message:String = null):void + { + failNotNull(actual, message); + } + + /** + * Asserts that the provided value is not null. + */ + public static function assertNotNull(actual:*, message:String = null):void + { + failNull(actual, message); + } + + /** + * Fails. + */ + public static function fail(message:String = "", sourceError:Error = null):void + { + throw new AssertionError(message, sourceError); + } + + /** + * Fails if the condition is true. + */ + public static function failTrue(condition:*, message:String = null):void + { + if(condition) + { + failWithUserMessage("expected false but was true", message); + } + } + + /** + * Fails if the condition is false. + */ + public static function failFalse(condition:*, message:String = null):void + { + if(!condition) + { + failWithUserMessage("expected true but was false", message); + } + } + + /** + * Fails if the values are loosely equal. + */ + public static function failEquals(actual:*, expected:*, message:String = null):void + { + if(actual == expected) + { + failWithUserMessage("expected: <" + expected + "> not to be equal to <" + actual + ">", message); + } + } + + /** + * Fails if the values are not loosely equal. + */ + public static function failNotEquals(actual:*, expected:*, message:String = null):void + { + if(actual != expected) + { + failWithUserMessage("expected: <" + expected + "> to be equal to <" + actual + ">", message); + } + } + + /** + * Fails if the values are strictly equal. + */ + public static function failStrictlyEquals(actual:*, expected:*, message:String = null):void + { + if(actual === expected) + { + failWithUserMessage("expected: <" + expected + "> not to be strictly equal to <" + actual + ">", message); + } + } + + /** + * Fails if the values are not strictly equal. + */ + public static function failNotStrictlyEquals(actual:*, expected:*, message:String = null):void + { + if(actual !== expected) + { + failWithUserMessage("expected: <" + expected + "> to be strictly equal to <" + actual + ">", message); + } + } + + /** + * Fails if the value is null. + */ + public static function failNull(object:*, message:String = null):void + { + if(object == null) + { + failWithUserMessage("expected not null", message); + } + } + + /** + * Fails if the value is not null. + */ + public static function failNotNull(object:*, message:String = null):void + { + if(object != null) + { + failWithUserMessage("expected null: <" + object + ">", message); + } + } + + /** + * @private + */ + protected static function failWithUserMessage(userMessage:String, failMessage:String = null):void + { + if(failMessage) + { + throw new AssertionError(userMessage + " - " + failMessage); + } + + throw new AssertionError(userMessage); + } + } +} \ No newline at end of file diff --git a/frameworks/projects/Testing/src/test/royale/NodeTests.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/AssertionError.as similarity index 50% copy from frameworks/projects/Testing/src/test/royale/NodeTests.as copy to frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/AssertionError.as index 804f89b..e974343 100644 --- a/frameworks/projects/Testing/src/test/royale/NodeTests.as +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/AssertionError.as @@ -16,39 +16,56 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package +package org.apache.royale.test { - import org.apache.royale.test.TestRunner; - import org.apache.royale.test.events.TestEvent; - import org.apache.royale.test.listeners.TraceListener; - import tests.ScopeTests; - import tests.DetectMetadataTests; - - public class NodeTests + /** + * Error class used when assertions fail. + * + * @see org.apache.royale.test.Assert + */ + public class AssertionError extends Error { - public function NodeTests() + COMPILE::JS + /** + * Constructor. + * + * @param message The assertion failure message + * @param error An optional error that caused the assertion failure + */ + public function AssertionError(message:String, error:Error = null) { - this._runner = new TestRunner(); - new TraceListener(this._runner); - this._runner.addEventListener(TestEvent.TEST_RUN_COMPLETE, runner_testRunCompleteHandler); - this._runner.addEventListener(TestEvent.TEST_RUN_FAIL, runner_testRunFailHandler); - this._runner.run(new - [ - DetectMetadataTests, - ScopeTests, - ]); + this.message = message; + if(error) + { + stack = error.stack; + } + else + { + stack = message + " " + (new Error()).stack; + } } - private var _runner:TestRunner; - - private function runner_testRunCompleteHandler(event:TestEvent):void + COMPILE::SWF + /** + * Constructor. + * + * @param message The assertion failure message + * @param error An optional error that caused the assertion failure + */ + public function AssertionError(message:String, error:Error = null) { - process.exit(0); + this.message = message; + if(error) + { + stack = error.getStackTrace(); + } + else + { + stack = message + " " + (new Error()).getStackTrace(); + } } - private function runner_testRunFailHandler(event:TestEvent):void - { - process.exit(1); - } + COMPILE::SWF + public var stack:String; } } \ No newline at end of file diff --git a/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/RoyaleUnitCore.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/RoyaleUnitCore.as new file mode 100644 index 0000000..506ac68 --- /dev/null +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/RoyaleUnitCore.as @@ -0,0 +1,315 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.royale.test +{ + import org.apache.royale.events.Event; + import org.apache.royale.events.EventDispatcher; + import org.apache.royale.test.runners.ITestRunner; + import org.apache.royale.test.runners.notification.Failure; + import org.apache.royale.test.runners.notification.IAsyncStartupRunListener; + import org.apache.royale.test.runners.notification.IRunListener; + import org.apache.royale.test.runners.notification.IRunNotifier; + import org.apache.royale.test.runners.notification.Result; + + /** + * Simple entry point for running tests. + */ + public class RoyaleUnitCore extends EventDispatcher + { + /** + * Constructor. + */ + public function RoyaleUnitCore() + { + } + + /** + * @private + */ + protected var _runner:ITestRunner = null; + + /** + * @private + */ + protected var _listeners:Vector. = new []; + + /** + * Requests that the runner stops running the tests. Phrased politely + * because the test that is currently running may not be interrupted + * before completing. + */ + public function pleaseStop():void + { + if(!_runner) + { + return; + } + _runner.pleaseStop(); + } + + /** + * Adds a run listener. + */ + public function addListener(listener:IRunListener):void + { + var index:int = _listeners.indexOf(listener); + if(index !== -1) + { + return; + } + _listeners.push(listener); + } + + /** + * Removes a run listener. + */ + public function removeListener(listener:IRunListener):void + { + var index:int = _listeners.indexOf(listener); + if(index === -1) + { + return; + } + _listeners.removeAt(index); + } + + /** + * @private + */ + public function runRunner(runner:ITestRunner):void + { + if(_runner) + { + throw new Error("Failed to run tests. Wait for previous test run to complete before starting again."); + } + + _runner = runner; + + var allListenersReady:Boolean = true; + var listenersLength:int = _listeners.length; + for(var i:int = 0; i < listenersLength; i++) + { + var listener:IRunListener = _listeners[i]; + if(listener is IAsyncStartupRunListener) + { + var asyncListener:IAsyncStartupRunListener = IAsyncStartupRunListener(listener); + if(!asyncListener.ready) + { + allListenersReady = false; + asyncListener.addEventListener("ready", asyncListener_readyHandler); + asyncListener.addEventListener("skip", asyncListener_skipHandler); + } + } + } + + if(allListenersReady) + { + startRun(); + } + } + + /** + * @private + */ + protected function startRun():void + { + var runner:ITestRunner = _runner; + + var notifier:IRunNotifier = new RootRunNotifier(testRunFinished); + var listenersLength:int = _listeners.length; + for(var i:int = 0; i < listenersLength; i++) + { + var listener:IRunListener = _listeners[i]; + notifier.addListener(_listeners[i]); + } + + try + { + _runner.run(notifier); + } + catch(error:Error) + { + notifier.fireTestFailure(new Failure(runner.description, error)); + finishRunner(); + } + } + + /** + * @private + */ + public function runClasses(testClass:Class, ...rest:Array):void + { + var classes:Vector. = new []; + var classCount:int = rest.length; + for(var i:int = 0; i < classCount; i++) + { + var item:* = rest[i]; + if(item is Class) + { + classes[i] = rest[i]; + } + else + { + throw new Error("Not a class: " + item); + } + } + classes.unshift(testClass); + runRunner(new ClassesRunner(classes)); + } + + /** + * @private + */ + protected function finishRunner():void + { + _runner = null; + dispatchEvent(new Event(Event.COMPLETE)); + } + + /** + * @private + */ + protected function testRunFinished(result:Result):void + { + finishRunner(); + } + + /** + * @private + */ + protected function checkListenersReady():void + { + var allListenersReady:Boolean = true; + var listenersLength:int = _listeners.length; + for(var i:int = 0; i < listenersLength; i++) + { + var listener:IRunListener = _listeners[i]; + if(listener is IAsyncStartupRunListener) + { + var asyncListener:IAsyncStartupRunListener = IAsyncStartupRunListener(listener); + if(asyncListener.ready) + { + asyncListener.removeEventListener("skip", asyncListener_skipHandler); + asyncListener.removeEventListener("ready", asyncListener_readyHandler); + } + else + { + allListenersReady = false; + } + } + } + + if(allListenersReady) + { + startRun(); + } + } + + /** + * @private + */ + protected function asyncListener_skipHandler(event:Event):void + { + var listener:IAsyncStartupRunListener = IAsyncStartupRunListener(event.currentTarget); + listener.removeEventListener("skip", asyncListener_skipHandler); + listener.removeEventListener("ready", asyncListener_readyHandler); + removeListener(listener); + checkListenersReady(); + } + + /** + * @private + */ + protected function asyncListener_readyHandler(event:Event):void + { + checkListenersReady(); + } + } +} + +import org.apache.royale.test.runners.ITestRunner; +import org.apache.royale.test.runners.ParentRunner; +import org.apache.royale.test.runners.notification.IRunListener; +import org.apache.royale.test.runners.notification.IRunNotifier; +import org.apache.royale.test.runners.notification.Result; +import org.apache.royale.test.runners.notification.RunNotifier; + +/** + * An internal runner for a collection of classes. + */ +class ClassesRunner extends ParentRunner implements ITestRunner +{ + /** + * Constructor. + */ + public function ClassesRunner(classes:Vector.) + { + super(); + if(!classes) + { + throw new Error("Test classes collection must not be null."); + } + _classes = classes; + } + + /** + * @private + */ + private var _classes:Vector. = null; + + /** + * @private + */ + override public function get description():String + { + return "RoyaleUnitCore"; + } + + /** + * @private + */ + override protected function collectChildren(result:Vector.):void + { + if(!_classes) + { + return; + } + var classCount:int = _classes.length; + for(var i:int = 0; i < classCount; i++) + { + result.push(_classes[i]); + } + } +} + +class RootRunNotifier extends RunNotifier +{ + public function RootRunNotifier(testRunFinishedCallback:Function) + { + _testRunFinishedCallback = testRunFinishedCallback; + } + + private var _testRunFinishedCallback:Function = null; + + override public function fireTestRunFinished(result:Result):void + { + super.fireTestRunFinished(result); + this._testRunFinishedCallback(result); + } +} \ No newline at end of file diff --git a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertEquals.as similarity index 77% copy from frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as copy to frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertEquals.as index 4b0ecfc..75e6d46 100644 --- a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertEquals.as @@ -16,12 +16,15 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package flexUnitTests +package org.apache.royale.test.asserts { - [Suite] - [RunWith("org.flexunit.runners.Suite")] - public class DataGridColumnTester - { - public var dataGridColumnTest:DataGridColumnTest; - } -} + import org.apache.royale.test.Assert; + + /** + * Alias for org.apache.royale.test.Assert assertEquals method + */ + public function assertEquals(actual:*, expected:*, message:String = null):void + { + Assert.assertEquals(actual, expected, message); + } +} \ No newline at end of file diff --git a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertFalse.as similarity index 78% copy from frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as copy to frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertFalse.as index 4b0ecfc..52d0fe0 100644 --- a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertFalse.as @@ -16,12 +16,15 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package flexUnitTests +package org.apache.royale.test.asserts { - [Suite] - [RunWith("org.flexunit.runners.Suite")] - public class DataGridColumnTester - { - public var dataGridColumnTest:DataGridColumnTest; - } -} + import org.apache.royale.test.Assert; + + /** + * Alias for org.apache.royale.test.Assert assertFalse method + */ + public function assertFalse(condition:*, message:String = null):void + { + Assert.assertFalse(condition, message); + } +} \ No newline at end of file diff --git a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertNotEquals.as similarity index 76% copy from frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as copy to frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertNotEquals.as index 4b0ecfc..d6c6312 100644 --- a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertNotEquals.as @@ -16,12 +16,15 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package flexUnitTests +package org.apache.royale.test.asserts { - [Suite] - [RunWith("org.flexunit.runners.Suite")] - public class DataGridColumnTester - { - public var dataGridColumnTest:DataGridColumnTest; - } -} + import org.apache.royale.test.Assert; + + /** + * Alias for org.apache.royale.test.Assert assertNotEquals method + */ + public function assertNotEquals(actual:*, expected:*, message:String = null):void + { + Assert.assertNotEquals(actual, expected, message); + } +} \ No newline at end of file diff --git a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertNotNull.as similarity index 78% copy from frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as copy to frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertNotNull.as index 4b0ecfc..c2e8fea 100644 --- a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertNotNull.as @@ -16,12 +16,15 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package flexUnitTests +package org.apache.royale.test.asserts { - [Suite] - [RunWith("org.flexunit.runners.Suite")] - public class DataGridColumnTester - { - public var dataGridColumnTest:DataGridColumnTest; - } -} + import org.apache.royale.test.Assert; + + /** + * Alias for org.apache.royale.test.Assert assertNotNull method + */ + public function assertNotNull(value:*, message:String = null):void + { + Assert.assertNotNull(value, message); + } +} \ No newline at end of file diff --git a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertNotStrictlyEquals.as similarity index 75% copy from frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as copy to frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertNotStrictlyEquals.as index 4b0ecfc..de72ec8 100644 --- a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertNotStrictlyEquals.as @@ -16,12 +16,15 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package flexUnitTests +package org.apache.royale.test.asserts { - [Suite] - [RunWith("org.flexunit.runners.Suite")] - public class DataGridColumnTester - { - public var dataGridColumnTest:DataGridColumnTest; - } -} + import org.apache.royale.test.Assert; + + /** + * Alias for org.apache.royale.test.Assert assertNotStrictlyEquals method + */ + public function assertNotStrictlyEquals(actual:*, expected:*, message:String = null):void + { + Assert.assertNotStrictlyEquals(actual, expected, message); + } +} \ No newline at end of file diff --git a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertNull.as similarity index 78% copy from frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as copy to frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertNull.as index 4b0ecfc..709f98d 100644 --- a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertNull.as @@ -16,12 +16,15 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package flexUnitTests +package org.apache.royale.test.asserts { - [Suite] - [RunWith("org.flexunit.runners.Suite")] - public class DataGridColumnTester - { - public var dataGridColumnTest:DataGridColumnTest; - } -} + import org.apache.royale.test.Assert; + + /** + * Alias for org.apache.royale.test.Assert assertNull method + */ + public function assertNull(value:*, message:String = null):void + { + Assert.assertNull(value, message); + } +} \ No newline at end of file diff --git a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertStrictlyEquals.as similarity index 75% copy from frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as copy to frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertStrictlyEquals.as index 4b0ecfc..24b1e8e 100644 --- a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertStrictlyEquals.as @@ -16,12 +16,15 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package flexUnitTests +package org.apache.royale.test.asserts { - [Suite] - [RunWith("org.flexunit.runners.Suite")] - public class DataGridColumnTester - { - public var dataGridColumnTest:DataGridColumnTest; - } -} + import org.apache.royale.test.Assert; + + /** + * Alias for org.apache.royale.test.Assert assertStrictlyEquals method + */ + public function assertStrictlyEquals(actual:*, expected:*, message:String = null):void + { + Assert.assertStrictlyEquals(actual, expected, message); + } +} \ No newline at end of file diff --git a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertTrue.as similarity index 78% copy from frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as copy to frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertTrue.as index 4b0ecfc..4cee4d2 100644 --- a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertTrue.as @@ -16,12 +16,15 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package flexUnitTests +package org.apache.royale.test.asserts { - [Suite] - [RunWith("org.flexunit.runners.Suite")] - public class DataGridColumnTester - { - public var dataGridColumnTest:DataGridColumnTest; - } -} + import org.apache.royale.test.Assert; + + /** + * Alias for org.apache.royale.test.Assert assertTrue method + */ + public function assertTrue(condition:*, message:String = null):void + { + Assert.assertTrue(condition, message); + } +} \ No newline at end of file diff --git a/frameworks/projects/HTML/src/test/royale/flexUnitTests/DataGridColumnTester.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/fail.as similarity index 81% rename from frameworks/projects/HTML/src/test/royale/flexUnitTests/DataGridColumnTester.as rename to frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/fail.as index d10c4c0..a1738ac 100644 --- a/frameworks/projects/HTML/src/test/royale/flexUnitTests/DataGridColumnTester.as +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/fail.as @@ -16,12 +16,15 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package flexUnitTests +package org.apache.royale.test.asserts { - [Suite] - [RunWith("org.flexunit.runners.Suite")] - public class DataGridColumnTester - { - public var dataGridColumnTesterTest:DataGridColumnTesterTest; - } -} + import org.apache.royale.test.Assert; + + /** + * Alias for org.apache.royale.test.Assert fail method + */ + public function fail(message:String = null):void + { + Assert.fail(message); + } +} \ No newline at end of file diff --git a/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/listeners/CIListener.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/listeners/CIListener.as new file mode 100644 index 0000000..7b90b0b --- /dev/null +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/listeners/CIListener.as @@ -0,0 +1,397 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.royale.test.listeners +{ + import org.apache.royale.events.EventDispatcher; + import org.apache.royale.test.AssertionError; + import org.apache.royale.test.runners.notification.Failure; + import org.apache.royale.test.runners.notification.IAsyncStartupRunListener; + import org.apache.royale.test.runners.notification.Result; + + COMPILE::SWF + { + import flash.events.DataEvent; + import flash.events.Event; + import flash.events.IOErrorEvent; + import flash.events.SecurityErrorEvent; + import flash.events.TimerEvent; + import flash.net.XMLSocket; + import flash.utils.Timer; + } + + COMPILE::SWF + public class CIListener extends EventDispatcher implements IAsyncStartupRunListener + { + /** + * @private + */ + protected static const DEFAULT_PORT:uint = 1024; + + /** + * @private + */ + protected static const DEFAULT_SERVER:String = "127.0.0.1"; + + /** + * @private + */ + protected static const STATUS_SUCCESS:String = "success"; + + /** + * @private + */ + protected static const STATUS_ERROR:String = "error"; + + /** + * @private + */ + protected static const STATUS_FAILURE:String = "failure"; + + /** + * @private + */ + protected static const STATUS_IGNORE:String = "ignore"; + + /** + * @private + */ + protected static const END_OF_TEST_RUN:String = ""; + + /** + * @private + */ + protected static const END_OF_TEST_ACK:String = ""; + + /** + * @private + */ + protected static const START_OF_TEST_RUN_ACK:String = ""; + + /** + * Constructor. + */ + public function CIListener(port:uint = DEFAULT_PORT, server:String = DEFAULT_SERVER) + { + _port = port; + _server = server; + + _socket = new XMLSocket(); + _socket.addEventListener(DataEvent.DATA, socket_dataHandler); + _socket.addEventListener(Event.CONNECT, socket_connectHandler); + _socket.addEventListener(IOErrorEvent.IO_ERROR, socket_errorHandler); + _socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, socket_errorHandler); + _socket.addEventListener(Event.CLOSE, socket_errorHandler); + + socketTimeOutTimer = new Timer(2000, 1); + socketTimeOutTimer.addEventListener(TimerEvent.TIMER_COMPLETE, socketTimeOutTimer_timerCompleteHandler, false, 0, true); + socketTimeOutTimer.start(); + + try + { + _socket.connect(server, port); + socketTimeOutTimer.stop(); + } + catch(e:Error) + { + //This needs to be more than a trace + trace(e.message); + } + } + + protected var _socket:XMLSocket; + protected var _port:uint; + protected var _server:String; + + protected var lastTestFailed:Boolean = false; + protected var socketTimeOutTimer:Timer = null; + protected var lastTestTime:Number = 123; + + protected var _ready:Boolean = false; + + /** + * @inheritDoc + */ + public function get ready():Boolean + { + return _ready; + } + + /** + * @private + */ + public function testTimed(description:String, runTime:Number):void + { + if(!runTime || isNaN(runTime)) + { + lastTestTime = 0; + } + else + { + lastTestTime = runTime; + } + } + + /** + * @private + */ + public function testRunStarted(description:String):void + { + //Since description tells us nothing about failure, error, and skip counts, this is + //computed by the Ant task as the process executes and no work is needed to signify + //the start of a test run. + } + + /** + * @private + */ + public function testRunFinished(result:Result):void + { + sendResults(END_OF_TEST_RUN); + } + + /** + * @private + */ + public function testStarted(description:String):void + { + lastTestFailed = false; + } + + /** + * @private + */ + public function testFinished(description:String):void + { + if(lastTestFailed) + { + return; + } + var descriptor:Descriptor = getDescriptorFromDescription(description); + + //we can't use the XML class here because FlexUnit expects the + //whitespace in the XML to be formatted in an exact way + var xml:String = + "" + + sendResults(xml); + } + + /** + * @private + */ + protected function escapeXML(value:String):String + { + if(value == null) + { + return ""; + } + var xml:XML = ; + return xml.@value.toXMLString(); + } + + /** + * @private + */ + public function testIgnored(description:String):void + { + var descriptor:Descriptor = getDescriptorFromDescription(description); + + //we can't use the XML class here because FlexUnit expects the + //whitespace in the XML to be formatted in an exact way + var xml:String = + "" + + "" + + ""; + + sendResults(xml); + } + + /** + * @private + */ + public function testFailure(failure:Failure):void + { + lastTestFailed = true; + var descriptor:Descriptor = getDescriptorFromDescription(failure.description); + + var xml:String = null; + if(failure.exception is AssertionError) + { + //we can't use the XML class here because FlexUnit expects the + //whitespace in the XML to be formatted in an exact way + xml = + "" + + "" + + "" + + "" + + ""; + } + else + { + //we can't use the XML class here because FlexUnit expects the + //whitespace in the XML to be formatted in an exact way + xml = + "" + + "" + + "" + + "" + + ""; + } + + sendResults(xml); + } + + /** + * @private + */ + private function getDescriptorFromDescription(description:String):Descriptor + { + var descriptor:Descriptor = new Descriptor(); + var descriptionArray:Array = description.split("::"); + var classMethod:String; + if(descriptionArray.length > 1) + { + descriptor.path = descriptionArray[0]; + classMethod = descriptionArray[1]; + } + else + { + classMethod = descriptionArray[0]; + } + var classMethodArray:Array = classMethod.split("."); + if(descriptor.path == "") + { + descriptor.suite = classMethodArray[0]; + } + else + { + descriptor.suite = descriptor.path + "::" + classMethodArray[0]; + } + if(classMethodArray.length > 1) + { + descriptor.method = classMethodArray[1]; + } + else + { + descriptor.method = ""; + } + return descriptor; + } + + /** + * @private + */ + protected function sendResults(msg:String):void + { + if(_socket.connected) + { + _socket.send(msg); + } + + trace(msg); + } + + /** + * @private + */ + protected function socketTimeOutTimer_timerCompleteHandler(event:TimerEvent):void + { + trace("Socket timeout in CIListener"); + dispatchEvent(new org.apache.royale.events.Event("skip")); + } + + /** + * @private + */ + protected function socket_connectHandler(event:flash.events.Event):void + { + //we're not "ready" yet. wait until we get some data first. + } + + /** + * @private + */ + protected function socket_errorHandler(event:flash.events.Event):void + { + trace("Socket error in CIListener"); + trace(event); + dispatchEvent(new org.apache.royale.events.Event("skip")); + } + + /** + * @private + */ + protected function socket_dataHandler(event:DataEvent):void + { + var data:String = event.data; + + //if we received an acknowledgement on startup, the java server is ready and we can start sending. + if(data == START_OF_TEST_RUN_ACK) + { + _ready = true; + dispatchEvent(new org.apache.royale.events.Event("ready")); + } + else if(data == END_OF_TEST_ACK) + { + //if we received an acknowledgement finish-up, close the socket. + _socket.close(); + } + } + } +} + +class Descriptor +{ + public function Descriptor(path:String = "", suite:String = "", method:String = "") + { + this.path = path; + this.suite = suite; + this.method = method; + } + + public var path:String; + public var suite:String; + public var method:String; +} \ No newline at end of file diff --git a/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/listeners/FailureListener.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/listeners/FailureListener.as new file mode 100644 index 0000000..e09d54b --- /dev/null +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/listeners/FailureListener.as @@ -0,0 +1,92 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.royale.test.listeners +{ + import org.apache.royale.test.runners.notification.Failure; + import org.apache.royale.test.runners.notification.IRunListener; + import org.apache.royale.test.runners.notification.Result; + + /** + * Determine if a test run fails or not. + */ + public class FailureListener implements IRunListener + { + public function FailureListener() + { + } + + /** + * @private + */ + protected var _failed:Boolean = false; + + /** + * Indicates of the test runner failed. + */ + public function get failed():Boolean + { + return _failed; + } + + /** + * @private + */ + public function testStarted(description:String):void + { + } + + /** + * @private + */ + public function testFinished(description:String):void + { + } + + /** + * @private + */ + public function testFailure(failure:Failure):void + { + _failed = true; + } + + /** + * @private + */ + public function testIgnored(description:String):void + { + } + + /** + * @private + */ + public function testRunStarted(description:String):void + { + _failed = false; + } + + /** + * @private + */ + public function testRunFinished(result:Result):void + { + _failed = _failed || !result.successful; + } + } +} \ No newline at end of file diff --git a/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/listeners/TraceListener.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/listeners/TraceListener.as new file mode 100644 index 0000000..9239781 --- /dev/null +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/listeners/TraceListener.as @@ -0,0 +1,185 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.royale.test.listeners +{ + import org.apache.royale.test.AssertionError; + import org.apache.royale.test.runners.notification.Failure; + import org.apache.royale.test.runners.notification.IRunListener; + import org.apache.royale.test.runners.notification.Result; + + /** + * Outputs the status of a test run to the debug console. + */ + public class TraceListener implements IRunListener + { + /** + * @private + */ + public function TraceListener() + { + } + + /** + * @private + */ + protected var _startTime:Number = 0; + + /** + * @private + */ + protected var _testCount:int = 0; + + /** + * @private + */ + protected var _ignoreCount:int = 0; + + /** + * @private + */ + protected var _failures:Vector. = null; + + /** + * @private + */ + public function testStarted(description:String):void + { + trace(description + " ."); + } + + /** + * @private + */ + public function testFinished(description:String):void + { + _testCount++; + } + + /** + * @private + */ + public function testFailure(failure:Failure):void + { + _failures.push(failure); + + var error:Error = failure.exception; + if(error is AssertionError) + { + trace(failure.description + " F"); + } + else //some other error + { + trace(failure.description + " E"); + } + } + + /** + * @private + */ + public function testIgnored(description:String):void + { + _ignoreCount++; + trace(description + " I"); + } + + /** + * @private + */ + public function testRunStarted(description:String):void + { + _startTime = (new Date()).getTime(); + _testCount = 0; + _ignoreCount = 0; + _failures = new []; + } + + /** + * @private + */ + public function testRunFinished(result:Result):void + { + var totalTime:Number = ((new Date()).getTime() - _startTime) / 1000; + trace("Time: " + totalTime); + + if(_failures.length > 0) + { + if(_failures.length === 1) + { + trace("There was 1 failure:"); + } + else + { + trace("There were " + _failures.length + " failures:"); + } + for(var i:int = 0; i < _failures.length; i++) + { + trace((i + 1) + " " + getFailureMessage(_failures[i])); + } + } + + var testString:String = "tests"; + if(_testCount === 1) + { + testString = "test"; + } + + if(_ignoreCount > 0) + { + testString += ", " + _ignoreCount + " ignored"; + } + + if(_failures.length > 0) + { + var failureString:String = "failures"; + if(_failures.length === 1) + { + failureString = "failure"; + } + trace("FAILURE (" + _testCount + " " + testString + ", " + _failures.length + " " + failureString + ")"); + } + else + { + trace("OK (" + _testCount + " " + testString + ")"); + } + } + + /** + * @private + */ + protected function getFailureMessage(failure:Failure):String + { + var message:String = failure.description; + var exception:Error = failure.exception; + var errorMessage:String = exception.message; + if(exception.stack) + { + message += " " + exception.stack; + } + else if(exception.message) + { + message += " " + exception.message; + } + else + { + message += " " + exception; + } + return message; + } + } +} \ No newline at end of file diff --git a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/ITestRunner.as similarity index 65% copy from frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as copy to frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/ITestRunner.as index 4b0ecfc..9348d2c 100644 --- a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/ITestRunner.as @@ -16,12 +16,27 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package flexUnitTests +package org.apache.royale.test.runners { - [Suite] - [RunWith("org.flexunit.runners.Suite")] - public class DataGridColumnTester - { - public var dataGridColumnTest:DataGridColumnTest; - } -} + import org.apache.royale.test.runners.notification.IRunNotifier; + + public interface ITestRunner + { + /** + * A description of this test runner. + */ + function get description():String; + + /** + * Requests that the runner stops running the tests. Phrased politely + * because the test that is currently running may not be interrupted + * before completing. + */ + function pleaseStop():void; + + /** + * Runs the tests. + */ + function run(notifier:IRunNotifier):void; + } +} \ No newline at end of file diff --git a/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/MetadataRunner.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/MetadataRunner.as new file mode 100644 index 0000000..f7d5412 --- /dev/null +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/MetadataRunner.as @@ -0,0 +1,256 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.royale.test.runners +{ + import org.apache.royale.reflection.MethodDefinition; + import org.apache.royale.reflection.TypeDefinition; + import org.apache.royale.reflection.describeType; + import org.apache.royale.reflection.getQualifiedClassName; + import org.apache.royale.test.runners.notification.Failure; + import org.apache.royale.test.runners.notification.IRunListener; + import org.apache.royale.test.runners.notification.IRunNotifier; + import org.apache.royale.test.runners.notification.Result; + + /** + * Runs a class containing methods marked with [Test] metadata. + * + *

Also supports the following optional metadata:

+ * + *
    + *
  • Tests with [Ignore] metdata should be ignored (skipped).
  • + *
  • Methods with [Before] metadata are run before every individual test.
  • + *
  • Methods with [After] metadata are run after every individual test.
  • + *
  • Methods with [BeforeClass] metadata are run one time, before the first test.
  • + *
  • Methods with [AfterClass] metadata are run one time, after the final test.
  • + *
+ */ + public class MetadataRunner implements ITestRunner + { + /** + * Constructor. + */ + public function MetadataRunner(testClass:Class) + { + super(); + if(!testClass) + { + throw new Error("Test class must not be null."); + } + _testClass = testClass; + } + + /** + * @private + */ + public function get description():String + { + return getQualifiedClassName(_testClass); + } + + /** + * @private + */ + protected var _testClass:Class = null; + + /** + * @private + */ + protected var _failures:Boolean = false; + + /** + * @private + */ + protected var _stopRequested:Boolean = false; + + /** + * @inheritDoc + */ + public function pleaseStop():void + { + _stopRequested = true; + } + + /** + * @inheritDoc + */ + public function run(notifier:IRunNotifier):void + { + _failures = false; + _stopRequested = false; + + var result:Result = new Result(); + var listener:IRunListener = result.createListener(); + notifier.addListener(listener); + + notifier.fireTestRunStarted(description); + if(_testClass) + { + runTestMethods(new _testClass(), notifier); + } + else + { + _failures = true; + notifier.fireTestFailure(new Failure(description + ".initializationError", new Error("No tests specified."))); + } + notifier.removeListener(listener); + + notifier.fireTestRunFinished(result); + } + + /** + * @private + */ + protected function runTestMethods(target:Object, notifier:IRunNotifier):void + { + var beforeClass:Function = collectMethodWithMetadataTag(target, TestMetadata.BEFORE_CLASS); + var afterClass:Function = collectMethodWithMetadataTag(target, TestMetadata.AFTER_CLASS); + var before:Function = collectMethodWithMetadataTag(target, TestMetadata.BEFORE); + var after:Function = collectMethodWithMetadataTag(target, TestMetadata.AFTER); + var collectedTests:Vector. = new []; + collectTests(target, collectedTests); + var collectedCount:int = collectedTests.length; + if(collectedCount === 0) + { + throw new Error("No methods found with [Test] metadata. Did you forget to include the -keep-as3-metadata compiler option?") + } + if(beforeClass !== null) + { + beforeClass.apply(target); + } + for(var i:int = 0; i < collectedCount; i++) + { + try + { + var test:TestInfo = collectedTests[i]; + if(test.ignore) + { + notifier.fireTestIgnored(test.description); + continue; + } + notifier.fireTestStarted(test.description); + if(before !== null) + { + before.apply(target); + } + test.reference.apply(target); + if(after !== null) + { + after.apply(target); + } + } + catch(error:Error) + { + _failures = true; + notifier.fireTestFailure(new Failure(test.description, error)); + } + notifier.fireTestFinished(test.description); + } + if(afterClass !== null) + { + afterClass.apply(target); + } + } + + /** + * @private + */ + protected function collectMethodWithMetadataTag(target:Object, tagName:String):Function + { + var typeDefinition:TypeDefinition = describeType(target); + if(!typeDefinition) + { + return null; + } + var methods:Array = typeDefinition.methods; + var length:int = methods.length; + for(var i:int = 0; i < length; i++) + { + var method:MethodDefinition = methods[i]; + var metadata:Array = method.retrieveMetaDataByName(tagName); + if(metadata.length > 0) + { + return target[method.name]; + } + } + return null; + } + + /** + * @private + */ + protected function collectTests(target:Object, result:Vector.):void + { + var typeDefinition:TypeDefinition = describeType(target); + if(!typeDefinition) + { + return; + } + + var methods:Array = typeDefinition.methods; + var length:int = methods.length; + for(var i:int = 0; i < length; i++) + { + var method:MethodDefinition = methods[i]; + var testName:String = null; + var testFunction:Function = null; + var ignore:Boolean = false; + + var testMetadata:Array = method.retrieveMetaDataByName(TestMetadata.TEST); + if(testMetadata.length > 0) + { + var qualifiedName:String = typeDefinition.qualifiedName; + var qualifiedNameParts:Array = qualifiedName.split("."); + var lastPart:String = qualifiedNameParts.pop(); + qualifiedName = qualifiedNameParts.join("."); + if(qualifiedName.length > 0) + { + qualifiedName += "::"; + } + qualifiedName += lastPart; + testName = qualifiedName + "." + method.name; + trace(testName); + testFunction = target[method.name]; + } + var ignoreMetadata:Array = method.retrieveMetaDataByName(TestMetadata.IGNORE); + if(ignoreMetadata.length > 0) + { + ignore = true; + } + if(testName !== null) + { + result.push(new TestInfo(testName, testFunction, ignore)); + } + } + } + } +} + +class TestInfo +{ + public function TestInfo(name:String, reference:Function, ignore:Boolean) + { + this.description = name; + this.reference = reference; + this.ignore = ignore; + } + + public var description:String; + public var reference:Function; + public var ignore:Boolean; +} \ No newline at end of file diff --git a/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/ParentRunner.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/ParentRunner.as new file mode 100644 index 0000000..53c03eb --- /dev/null +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/ParentRunner.as @@ -0,0 +1,335 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.royale.test.runners +{ + import org.apache.royale.reflection.MetaDataArgDefinition; + import org.apache.royale.reflection.MetaDataDefinition; + import org.apache.royale.reflection.TypeDefinition; + import org.apache.royale.reflection.describeType; + import org.apache.royale.reflection.getDefinitionByName; + import org.apache.royale.test.runners.notification.Failure; + import org.apache.royale.test.runners.notification.IRunNotifier; + import org.apache.royale.test.runners.notification.Result; + + COMPILE::SWF + { + import flash.utils.setTimeout; + } + COMPILE::JS + { + import goog.global; + } + + /** + * Provides a base implementation of a runner with children, and intended to + * be subclassed. + */ + public class ParentRunner implements ITestRunner + { + /** + * @private + * Hard reference to required dependency. Not actually used. + */ + private static var _suiteRunner:SuiteRunner; + + /** + * Constructor. + */ + public function ParentRunner(children:Vector. = null) + { + if(Object(this).constructor === ParentRunner) + { + throw new Error("Class ParentRunner is abstract"); + } + _children = children; + } + + /** + * @private + */ + protected var _children:Vector. = null; + + /** + * @private + */ + protected var _currentRunner:ITestRunner = null; + + /** + * @inheritDoc + */ + public function get description():String + { + throw new Error("AbstractClassError: get description not implemented by <" + this + ">"); + } + + /** + * @private + */ + protected var _result:Result = null; + + /** + * @private + */ + protected var _notifier:IRunNotifier = null; + + /** + * @private + */ + protected var _failures:Boolean = false; + + /** + * @private + */ + protected var _stopRequested:Boolean = false; + + /** + * @inheritDoc + */ + public function pleaseStop():void + { + _stopRequested = true; + } + + /** + * @private + */ + public function run(notifier:IRunNotifier):void + { + _failures = false; + _stopRequested = false; + _children = new []; + _notifier = notifier; + _result = new Result(); + _notifier.addListener(_result.createListener()); + _notifier.fireTestRunStarted(description); + try + { + collectChildren(_children); + } + catch(error:Error) + { + _failures = true; + notifier.fireTestFailure(new Failure(description + ".initializationError", error)); + } + if(_children.length === 0) + { + _failures = true; + notifier.fireTestFailure(new Failure(description + ".initializationError", new Error("No children found"))); + } + nextChild(); + } + + /** + * @private + */ + protected function nextChild():void + { + _currentRunner = null; + if(_stopRequested) + { + _failures = true; + _notifier.fireTestFailure(new Failure(description, new Error("Stop requested"))); + _children.length = 0; + } + if(_children.length == 0) + { + var notifier:IRunNotifier = _notifier; + var result:Result = _result; + _notifier = null; + _result = null; + notifier.fireTestRunFinished(result); + notifier.removeListener(result.createListener()); + return; + } + COMPILE::JS + { + if("requestAnimationFrame" in goog.global) + { + goog.global["requestAnimationFrame"](createNextRunner); + } + else if("setImmediate" in goog.global) + { + goog.global["setImmediate"](createNextRunner); + } + else if("setTimeout" in goog.global) + { + goog.global["setTimeout"](createNextRunner, 0); + } + else + { + createNextRunner(); + } + } + COMPILE::SWF + { + setTimeout(createNextRunner, 0); + } + } + + /** + * @private + */ + protected function createNextRunner():void + { + //save this just in case it gets cleared later + var notifier:IRunNotifier = _notifier; + var child:Class = _children.pop(); + try + { + _currentRunner = createChildRunner(child); + var childNotifier:ChildNotifier = new ChildNotifier(_notifier, nextChild); + _currentRunner.run(childNotifier); + } + catch(error:Error) + { + _failures = true; + notifier.fireTestFailure(new Failure(description, error)); + nextChild(); + } + } + + /** + * Subclasses must override to collect all children for this parent + * runner. + */ + protected function collectChildren(result:Vector.):void + { + throw new Error("AbstractClassError: collectChildren() not implemented by <" + this + ">"); + } + + /** + * @private + */ + protected function createChildRunner(child:Class):ITestRunner + { + var typeDefinition:TypeDefinition = describeType(child); + if(!typeDefinition) + { + throw new Error("Could not find type definition for child <" + child + "> in test suite <" + description + ">"); + } + var runWithMetadata:Array = typeDefinition.retrieveMetaDataByName(TestMetadata.RUN_WITH); + if(runWithMetadata.length > 0) + { + var RunWithClass:Class = verifyRunWith(typeDefinition); + return new RunWithClass(child); + } + else + { + return new MetadataRunner(child); + } + } + + /** + * @private + */ + protected function verifyRunWith(typeDefinition:TypeDefinition):Class + { + if(!typeDefinition) + { + throw new Error("No test runner type has been specified"); + } + var runWithMetadata:Array = typeDefinition.retrieveMetaDataByName(TestMetadata.RUN_WITH); + if(runWithMetadata.length === 0) + { + throw new Error("Missing [RunWith] metadata on test runner: <" + typeDefinition.qualifiedName + ">"); + } + var metadata:MetaDataDefinition = runWithMetadata[0]; + if(metadata.args.length !== 1) + { + throw new Error("Invalid class reference in [RunWith] metadata on test runner: <" + typeDefinition.qualifiedName + ">"); + } + var arg:MetaDataArgDefinition = metadata.args[0]; + if(arg.key) + { + throw new Error("Unknown key <" + arg.key + "> in [RunWith] metadata on test runner: <" + typeDefinition.qualifiedName + ">"); + } + var runWithClassName:String = arg.value; + var RunWithClass:Class = getDefinitionByName(runWithClassName) as Class; + if(!RunWithClass) + { + throw new Error("Could not find test runner: <" + runWithClassName + ">"); + } + return RunWithClass; + } + } +} + +import org.apache.royale.test.runners.notification.Failure; +import org.apache.royale.test.runners.notification.IRunListener; +import org.apache.royale.test.runners.notification.IRunNotifier; +import org.apache.royale.test.runners.notification.Result; + +class ChildNotifier implements IRunNotifier +{ + public function ChildNotifier(parentNotifier:IRunNotifier, testRunFinishedCallback:Function) + { + _parentNotifier = parentNotifier; + _testRunFinishedCallback = testRunFinishedCallback; + } + + private var _parentNotifier:IRunNotifier + private var _testRunFinishedCallback:Function + + public function fireTestStarted(description:String):void + { + _parentNotifier.fireTestStarted(description); + } + + public function fireTestFinished(description:String):void + { + _parentNotifier.fireTestFinished(description); + } + + public function fireTestFailure(failure:Failure):void + { + _parentNotifier.fireTestFailure(failure); + } + + public function fireTestIgnored(description:String):void + { + _parentNotifier.fireTestIgnored(description); + } + + public function fireTestRunStarted(description:String):void + { + //don't notify the parent + } + + public function fireTestRunFinished(result:Result):void + { + //don't notify the parent + _testRunFinishedCallback(); + } + + public function addListener(listener:IRunListener):void + { + } + + public function addFirstListener(listener:IRunListener):void + { + } + + public function removeListener(listener:IRunListener):void + { + } + + public function removeAllListeners():void + { + } +} \ No newline at end of file diff --git a/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/SuiteRunner.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/SuiteRunner.as new file mode 100644 index 0000000..b5155c9 --- /dev/null +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/SuiteRunner.as @@ -0,0 +1,90 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.royale.test.runners +{ + import org.apache.royale.reflection.TypeDefinition; + import org.apache.royale.reflection.VariableDefinition; + import org.apache.royale.reflection.describeType; + import org.apache.royale.reflection.getDefinitionByName; + import org.apache.royale.reflection.getQualifiedClassName; + + /** + * A runner for test suites. Suites should be annotated with + * [Suite] and [RunWith] metadata. + */ + public class SuiteRunner extends ParentRunner implements ITestRunner + { + /** + * Constructor. + */ + public function SuiteRunner(suite:Class = null) + { + super(); + if(!suite) + { + throw new Error("Suite class must not be null."); + } + _suite = suite; + } + + /** + * @private + */ + private var _suite:Class = null; + + /** + * @private + */ + override public function get description():String + { + return getQualifiedClassName(_suite); + } + + /** + * @private + */ + override protected function collectChildren(result:Vector.):void + { + if(!_suite) + { + return; + } + + var typeDefinition:TypeDefinition = describeType(_suite); + + var variables:Array = typeDefinition.variables; + var length:int = variables.length; + for(var i:int = 0; i < length; i++) + { + var variable:VariableDefinition = variables[i]; + var variableType:TypeDefinition = variable.type; + if(!variableType) + { + continue; + } + var classRef:Object = getDefinitionByName(variableType.qualifiedName); + if(!classRef) + { + continue; + } + result.push(classRef); + } + } + } +} \ No newline at end of file diff --git a/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/TestMetadata.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/TestMetadata.as new file mode 100644 index 0000000..cf60871 --- /dev/null +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/TestMetadata.as @@ -0,0 +1,67 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.royale.test.runners +{ + /** + * @private + * Metadata used by tests. + */ + internal class TestMetadata + { + /** + * Indicates that a method is a test. + */ + public static const TEST:String = "Test"; + + /** + * Indicates that a [Test] method should be skipped. + */ + public static const IGNORE:String = "Ignore"; + + /** + * Indicates that a method runs before every [Test] method. + */ + public static const BEFORE:String = "Before"; + + /** + * Indicates that a method runs after every [Test] method. + */ + public static const AFTER:String = "After"; + + /** + * Indicates that a method should be run once before all + * [Test] methods in the class. + */ + public static const BEFORE_CLASS:String = "BeforeClass"; + + /** + * Indicates that a method should be run once after all + * [Test] methods in the class. + */ + public static const AFTER_CLASS:String = "AfterClass"; + + /** + * Indicates which ITestRunner should be used to run the + * tests in the class. + * + *
[RunWith("org.apache.test.runners.SuiteRunner")]
+ */ + public static const RUN_WITH:String = "RunWith"; + } +} \ No newline at end of file diff --git a/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/notification/Failure.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/notification/Failure.as new file mode 100644 index 0000000..3c53f76 --- /dev/null +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/notification/Failure.as @@ -0,0 +1,84 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.royale.test.runners.notification +{ + public class Failure + { + public function Failure(description:String, exception:Error) + { + _description = description; + _exception = exception; + _message = exception.message; + COMPILE::SWF + { + _stackTrace = exception.getStackTrace(); + } + COMPILE::JS + { + _stackTrace = exception.stack; + } + } + + /** + * @private + */ + protected var _description:String = null; + + /** + * The description of the test that failed. + */ + public function get description():String + { + return _description; + } + + /** + * @private + */ + protected var _exception:Error = null; + + /** + * The exception that caused the test to fail. + */ + public function get exception():Error + { + return _exception; + } + + protected var _stackTrace:String = null; + + /** + * Convenience method. + */ + public function get stackTrace():String + { + return _stackTrace; + } + + protected var _message:String = null; + + /** + * Convenience method. + */ + public function get message():String + { + return _message; + } + } +} \ No newline at end of file diff --git a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/notification/IAsyncStartupRunListener.as similarity index 62% copy from frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as copy to frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/notification/IAsyncStartupRunListener.as index 4b0ecfc..e9cf06a 100644 --- a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/notification/IAsyncStartupRunListener.as @@ -16,12 +16,28 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package flexUnitTests +package org.apache.royale.test.runners.notification { - [Suite] - [RunWith("org.flexunit.runners.Suite")] - public class DataGridColumnTester - { - public var dataGridColumnTest:DataGridColumnTest; - } -} + import org.apache.royale.events.IEventDispatcher; + + /** + * Dispatched when the listener should be skipped. + */ + [Event(name="skip",type="org.apache.royale.events.Event")] + + /** + * Dispatched when the listener is ready. + */ + [Event(name="ready",type="org.apache.royale.events.Event")] + + /** + * A listener that requires extra time to startup. + */ + public interface IAsyncStartupRunListener extends IRunListener, IEventDispatcher + { + /** + * Indicates if the listener is ready or not. + */ + function get ready():Boolean; + } +} \ No newline at end of file diff --git a/frameworks/projects/Testing/src/test/royale/tests/DetectMetadataTests.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/notification/IRunListener.as similarity index 53% rename from frameworks/projects/Testing/src/test/royale/tests/DetectMetadataTests.as rename to frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/notification/IRunListener.as index 2fb8916..d884ec4 100644 --- a/frameworks/projects/Testing/src/test/royale/tests/DetectMetadataTests.as +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/notification/IRunListener.as @@ -16,46 +16,42 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package tests +package org.apache.royale.test.runners.notification { - import org.apache.royale.test.TestRunner; - import org.apache.royale.test.Assert; - - public class DetectMetadataTests + /** + * Responds to events that occur during a test run. + */ + public interface IRunListener { - [Test] - public function testBeforeTestAfterMetadata():void - { - var runner:TestRunner = new TestRunner(); - runner.run(new [TestClass]); - Assert.true(TestClass.before); - Assert.true(TestClass.test); - Assert.true(TestClass.after); - } - } -} - -class TestClass -{ - public static var before:Boolean = false; - public static var after:Boolean = false; - public static var test:Boolean = false; - - [Before] - public function testBeforeMetadata():void - { - TestClass.before = true; - } - - [After] - public function testAfterMetadata():void - { - TestClass.after = true; - } - - [Test] - public function testTestMetadata():void - { - TestClass.test = true; + /** + * Called when an individual test has started. + */ + function testStarted(description:String):void; + + /** + * Called when an individual test has finished, regardless of whether it + * has passed or failed. + */ + function testFinished(description:String):void; + + /** + * Called when an individual test has failed. + */ + function testFailure(failure:Failure):void; + + /** + * Called when an individual test was ignored. + */ + function testIgnored(description:String):void; + + /** + * Called when a test run has started. + */ + function testRunStarted(description:String):void; + + /** + * Called when a test run has finished. + */ + function testRunFinished(result:Result):void; } } \ No newline at end of file diff --git a/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/notification/IRunNotifier.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/notification/IRunNotifier.as new file mode 100644 index 0000000..c92ea13 --- /dev/null +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/notification/IRunNotifier.as @@ -0,0 +1,77 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.royale.test.runners.notification +{ + /** + * Listens for notifications from an ITestRunner. + */ + public interface IRunNotifier + { + /** + * Notification when an individual test has started. + */ + function fireTestStarted(description:String):void; + + /** + * Notification when an individual test has finished, regardless of + * whether it passed or failed. + */ + function fireTestFinished(description:String):void; + + /** + * Notification when an individual test has failed. + */ + function fireTestFailure(failure:Failure):void; + + /** + * Notification when an individual test was ignored. + */ + function fireTestIgnored(description:String):void; + + /** + * Notification when a test run has started. + */ + function fireTestRunStarted(description:String):void; + + /** + * Notification when a test run has finished. + */ + function fireTestRunFinished(result:Result):void; + + /** + * Adds a listener. + */ + function addListener(listener:IRunListener):void; + + /** + * Adds a listener to the beginning of the collection of listeners. + */ + function addFirstListener(listener:IRunListener):void; + + /** + * Removes a listener. + */ + function removeListener(listener:IRunListener):void; + + /** + * Removes all listeners. + */ + function removeAllListeners():void; + } +} \ No newline at end of file diff --git a/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/notification/Result.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/notification/Result.as new file mode 100644 index 0000000..bde9e2e --- /dev/null +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/notification/Result.as @@ -0,0 +1,177 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.royale.test.runners.notification +{ + import org.apache.royale.test.runners.notification.IRunListener; + + /** + * The result of a test run. + */ + public class Result + { + /** + * Constructor. + */ + public function Result() + { + + } + + /** + * @private + */ + protected var _listener:ResultListener = null; + + /** + * The number of tests that failed. + */ + public function get failCount():int + { + return _listener.failures.length; + } + + /** + * The collection of test failures. + */ + public function get failures():Vector. + { + return _listener.failures; + } + + /** + * The number of tests that were ignored. + */ + public function get ignoreCount():int + { + return _listener.ignoreCount; + } + + /** + * The number of tests that were run, whether they passed or failed. + */ + public function get runCount():int + { + return _listener.runCount; + } + + /** + * The total run time of the test run, in milliseconds. + */ + public function get runTime():Number + { + return _listener.runTime; + } + + /** + * Indicates if the test run was successful or not. + */ + public function get successful():Boolean + { + return _listener.failures.length === 0; + } + + /** + * For internal use only. + */ + public function createListener():IRunListener + { + if(!_listener) + { + _listener = new ResultListener(this); + } + return _listener; + } + } +} + +import org.apache.royale.test.runners.notification.Failure; +import org.apache.royale.test.runners.notification.IRunListener; +import org.apache.royale.test.runners.notification.Result; + +class ResultListener implements IRunListener +{ + public function ResultListener(result:Result) + { + _result = result; + } + + private var _result:Result = null; + + private var _ignoreCount:int = 0; + + public function get ignoreCount():int + { + return _ignoreCount; + } + + private var _failures:Vector. = new []; + + public function get failures():Vector. + { + return _failures; + } + + private var _runCount:int = 0; + + public function get runCount():int + { + return _runCount; + } + + private var _startTime:Number = 0; + private var _runTime:Number = 0; + + public function get runTime():Number + { + return _runTime; + } + + public function testRunStarted(description:String):void + { + _startTime = (new Date()).getTime(); + _runTime = 0; + _runCount = 0; + _ignoreCount = 0; + _failures = new []; + } + + public function testRunFinished(result:Result):void + { + _runTime = ((new Date()).getTime() - _startTime); + } + + public function testStarted(description:String):void + { + } + + public function testFinished(description:String):void + { + _runCount++; + } + + public function testFailure(failure:Failure):void + { + _failures.push(failure); + } + + public function testIgnored(description:String):void + { + _ignoreCount++; + } +} \ No newline at end of file diff --git a/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/notification/RunNotifier.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/notification/RunNotifier.as new file mode 100644 index 0000000..6c04d6d --- /dev/null +++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/runners/notification/RunNotifier.as @@ -0,0 +1,171 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.royale.test.runners.notification +{ + /** + * Listens for notifications from an ITestRunner. + */ + public class RunNotifier implements IRunNotifier + { + /** + * Constructor. + */ + public function RunNotifier() + { + } + + /** + * @private + */ + private var _listeners:Vector. = new []; + + /** + * @inheritDoc + */ + public function addListener(listener:IRunListener):void + { + var index:int = _listeners.indexOf(listener); + if(index !== -1) + { + //already added + return; + } + _listeners.push(listener); + } + + /** + * @inheritDoc + */ + public function addFirstListener(listener:IRunListener):void + { + var index:int = _listeners.indexOf(listener); + if(index === 0) + { + //already added at the start + return; + } + if(index !== -1) + { + //remove so that we can add to the start + _listeners.removeAt(index); + } + _listeners.unshift(listener); + } + + /** + * @inheritDoc + */ + public function removeListener(listener:IRunListener):void + { + var index:int = _listeners.indexOf(listener); + if(index === -1) + { + //wasn't added + return; + } + _listeners.removeAt(index); + } + + /** + * @inheritDoc + */ + public function removeAllListeners():void + { + _listeners.length = 0; + } + + /** + * @inheritDoc + */ + public function fireTestStarted(description:String):void + { + var length:int = _listeners.length; + for(var i:int = 0; i < length; i++) + { + var listener:IRunListener = _listeners[i]; + listener.testStarted(description); + } + } + + /** + * @inheritDoc + */ + public function fireTestFinished(description:String):void + { + var length:int = _listeners.length; + for(var i:int = 0; i < length; i++) + { + var listener:IRunListener = _listeners[i]; + listener.testFinished(description); + } + } + + /** + * @inheritDoc + */ + public function fireTestFailure(failure:Failure):void + { + var length:int = _listeners.length; + for(var i:int = 0; i < length; i++) + { + var listener:IRunListener = _listeners[i]; + listener.testFailure(failure); + } + } + + /** + * @inheritDoc + */ + public function fireTestIgnored(description:String):void + { + var length:int = _listeners.length; + for(var i:int = 0; i < length; i++) + { + var listener:IRunListener = _listeners[i]; + listener.testIgnored(description); + } + } + + /** + * @inheritDoc + */ + public function fireTestRunStarted(description:String):void + { + var length:int = _listeners.length; + for(var i:int = 0; i < length; i++) + { + var listener:IRunListener = _listeners[i]; + listener.testRunStarted(description); + } + } + + /** + * @inheritDoc + */ + public function fireTestRunFinished(result:Result):void + { + var length:int = _listeners.length; + for(var i:int = 0; i < length; i++) + { + var listener:IRunListener = _listeners[i]; + listener.testRunFinished(result); + } + } + } +} \ No newline at end of file diff --git a/frameworks/projects/Core/src/test/royale/FlexUnitRoyaleApplication-config.xml b/frameworks/projects/RoyaleUnit/src/test/royale/FlexUnitRoyaleApplication-config.xml similarity index 77% copy from frameworks/projects/Core/src/test/royale/FlexUnitRoyaleApplication-config.xml copy to frameworks/projects/RoyaleUnit/src/test/royale/FlexUnitRoyaleApplication-config.xml index 7063b81..35f42eb 100644 --- a/frameworks/projects/Core/src/test/royale/FlexUnitRoyaleApplication-config.xml +++ b/frameworks/projects/RoyaleUnit/src/test/royale/FlexUnitRoyaleApplication-config.xml @@ -37,20 +37,16 @@ ../../../../../libs/Basic.swc - ../../../../../libs/Binding.swc ../../../../../libs/Core.swc - ../../../../../libs/Graphics.swc - ../../../../../libs/Collections.swc - ../../../../../libs/Testing.swc + ../../../../../libs/Reflection.swc + ../../../../../libs/RoyaleUnit.swc ../../../../../js/libs/BasicJS.swc - ../../../../../js/libs/BindingJS.swc ../../../../../js/libs/CoreJS.swc - ../../../../../js/libs/GraphicsJS.swc - ../../../../../js/libs/CollectionsJS.swc - ../../../../../js/libs/TestingJS.swc + ../../../../../js/libs/ReflectionJS.swc + ../../../../../js/libs/RoyaleUnitJS.swc true @@ -79,18 +75,21 @@ NonCommittingChangeEvent Transient SWFOverride + + + Test + Before + After + BeforeClass + AfterClass + Ignore + Suite + RunWith - - - - library://ns.apache.org/royale/basic - ../../main/resources/basic-manifest.xml - - false diff --git a/frameworks/projects/HTML/src/test/royale/FlexUnitRoyaleApplication.mxml b/frameworks/projects/RoyaleUnit/src/test/royale/FlexUnitRoyaleApplication.mxml similarity index 70% rename from frameworks/projects/HTML/src/test/royale/FlexUnitRoyaleApplication.mxml rename to frameworks/projects/RoyaleUnit/src/test/royale/FlexUnitRoyaleApplication.mxml index d0e6f1c..3c7a0e7 100644 --- a/frameworks/projects/HTML/src/test/royale/FlexUnitRoyaleApplication.mxml +++ b/frameworks/projects/RoyaleUnit/src/test/royale/FlexUnitRoyaleApplication.mxml @@ -20,21 +20,30 @@ limitations under the License. + + + diff --git a/frameworks/projects/Testing/src/test/royale/NodeTests.as b/frameworks/projects/RoyaleUnit/src/test/royale/NodeTests.as similarity index 58% rename from frameworks/projects/Testing/src/test/royale/NodeTests.as rename to frameworks/projects/RoyaleUnit/src/test/royale/NodeTests.as index 804f89b..b505b5d 100644 --- a/frameworks/projects/Testing/src/test/royale/NodeTests.as +++ b/frameworks/projects/RoyaleUnit/src/test/royale/NodeTests.as @@ -18,37 +18,38 @@ //////////////////////////////////////////////////////////////////////////////// package { - import org.apache.royale.test.TestRunner; - import org.apache.royale.test.events.TestEvent; + import org.apache.royale.events.Event; + import org.apache.royale.test.RoyaleUnitCore; + import org.apache.royale.test.listeners.FailureListener; import org.apache.royale.test.listeners.TraceListener; - import tests.ScopeTests; - import tests.DetectMetadataTests; + + import tests.RoyaleUnitSuite; public class NodeTests { public function NodeTests() { - this._runner = new TestRunner(); - new TraceListener(this._runner); - this._runner.addEventListener(TestEvent.TEST_RUN_COMPLETE, runner_testRunCompleteHandler); - this._runner.addEventListener(TestEvent.TEST_RUN_FAIL, runner_testRunFailHandler); - this._runner.run(new - [ - DetectMetadataTests, - ScopeTests, - ]); + this._failureListener = new FailureListener(); + this._royaleUnit = new RoyaleUnitCore(); + this._royaleUnit.addListener(new TraceListener()); + this._royaleUnit.addListener(this._failureListener); + this._royaleUnit.addEventListener(Event.COMPLETE, royaleUnit_completeHandler); + this._royaleUnit.runClasses( + RoyaleUnitSuite + ); } - private var _runner:TestRunner; - - private function runner_testRunCompleteHandler(event:TestEvent):void - { - process.exit(0); - } + private var _royaleUnit:RoyaleUnitCore; + private var _failureListener:FailureListener; - private function runner_testRunFailHandler(event:TestEvent):void + private function royaleUnit_completeHandler(event:Event):void { - process.exit(1); + var exitCode:int = 0; + if(_failureListener.failed) + { + exitCode = 1; + } + process.exit(exitCode); } } } \ No newline at end of file diff --git a/frameworks/projects/RoyaleUnit/src/test/royale/asconfig.json b/frameworks/projects/RoyaleUnit/src/test/royale/asconfig.json new file mode 100644 index 0000000..0cb11a7 --- /dev/null +++ b/frameworks/projects/RoyaleUnit/src/test/royale/asconfig.json @@ -0,0 +1,35 @@ +{ + "config": "node", + "compilerOptions": { + "keep-as3-metadata": [ + "Test", + "Before", + "After", + "BeforeClass", + "AfterClass", + "Ignore", + "Suite", + "RunWith" + ], + "source-map": true, + "source-path": [ + ".", + ], + "library-path": [ + + "${royalelib}/libs/Language.swc", + "${royalelib}/libs/Core.swc", + "${royalelib}/libs/Reflection.swc", + "${royalelib}/libs/RoyaleUnit.swc" + ], + "js-library-path": [ + "${royalelib}/js/libs/LanguageJS.swc", + "${royalelib}/js/libs/CoreJS.swc", + "${royalelib}/js/libs/ReflectionJS.swc", + "${royalelib}/js/libs/RoyaleUnitJS.swc" + ] + }, + "files":[ + "NodeTests.as" + ] +} \ No newline at end of file diff --git a/frameworks/projects/HTML/src/test/royale/build.xml b/frameworks/projects/RoyaleUnit/src/test/royale/build.xml similarity index 75% rename from frameworks/projects/HTML/src/test/royale/build.xml rename to frameworks/projects/RoyaleUnit/src/test/royale/build.xml index 562435a..29cfc63 100644 --- a/frameworks/projects/HTML/src/test/royale/build.xml +++ b/frameworks/projects/RoyaleUnit/src/test/royale/build.xml @@ -19,7 +19,7 @@ --> - + @@ -27,7 +27,7 @@ - + @@ -42,24 +42,12 @@ type="dir" property="FLEXUNIT_HOME" value="${ROYALE_HOME}/in/flexunit" /> - + - - - - - - - + - - - - - - + - - - -
@@ -146,7 +129,7 @@ verbose="true" localTrusted="true" timeout="90000"> - + diff --git a/frameworks/projects/RoyaleUnit/src/test/royale/tests/BeforeAndAfterTests.as b/frameworks/projects/RoyaleUnit/src/test/royale/tests/BeforeAndAfterTests.as new file mode 100644 index 0000000..2d4687c --- /dev/null +++ b/frameworks/projects/RoyaleUnit/src/test/royale/tests/BeforeAndAfterTests.as @@ -0,0 +1,172 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package tests +{ + import org.apache.royale.test.Assert; + import org.apache.royale.test.runners.MetadataRunner; + import org.apache.royale.test.runners.notification.RunNotifier; + + public class BeforeAndAfterTests + { + private var _runner:MetadataRunner; + + [Before] + public function setUp():void + { + beforeRan = false; + afterRan = false; + testRan = false; + } + + [After] + public function tearDown():void + { + beforeRan = false; + afterRan = false; + testRan = false; + _runner = null; + } + + [Test] + public function testBefore():void + { + _runner = new MetadataRunner(BeforeFixture); + + Assert.assertFalse(beforeRan); + Assert.assertFalse(afterRan); + Assert.assertFalse(testRan); + + _runner.run(new RunNotifier()); + + Assert.assertTrue(beforeRan); + Assert.assertFalse(afterRan); + Assert.assertTrue(testRan); + } + + [Test] + public function testAfter():void + { + _runner = new MetadataRunner(AfterFixture); + + Assert.assertFalse(beforeRan); + Assert.assertFalse(afterRan); + Assert.assertFalse(testRan); + + _runner.run(new RunNotifier()); + + Assert.assertFalse(beforeRan); + Assert.assertTrue(afterRan); + Assert.assertTrue(testRan); + } + + [Test] + public function testBeforeAndAfter():void + { + _runner = new MetadataRunner(BeforeAndAfterFixture); + + Assert.assertFalse(beforeRan); + Assert.assertFalse(afterRan); + Assert.assertFalse(testRan); + + _runner.run(new RunNotifier()); + + Assert.assertTrue(beforeRan); + Assert.assertTrue(afterRan); + Assert.assertTrue(testRan); + } + } +} + +import org.apache.royale.test.Assert; + +var beforeRan:Boolean = false; +var afterRan:Boolean = false; +var testRan:Boolean = false; + +class BeforeFixture +{ + [Before] + public function before():void + { + Assert.assertFalse(beforeRan); + beforeRan = true; + Assert.assertFalse(testRan); + Assert.assertFalse(afterRan); + } + + [Test] + public function test():void + { + Assert.assertFalse(testRan); + testRan = true; + Assert.assertTrue(beforeRan); + Assert.assertFalse(afterRan); + } +} + +class AfterFixture +{ + [After] + public function after():void + { + Assert.assertFalse(afterRan); + afterRan = true; + Assert.assertFalse(beforeRan); + Assert.assertTrue(testRan); + } + + [Test] + public function test():void + { + Assert.assertFalse(testRan); + testRan = true; + Assert.assertFalse(beforeRan); + Assert.assertFalse(afterRan); + } +} + +class BeforeAndAfterFixture +{ + [Before] + public function before():void + { + Assert.assertFalse(beforeRan); + beforeRan = true; + Assert.assertFalse(testRan); + Assert.assertFalse(afterRan); + } + + [After] + public function after():void + { + Assert.assertFalse(afterRan); + afterRan = true; + Assert.assertTrue(beforeRan); + Assert.assertTrue(testRan); + } + + [Test] + public function test():void + { + Assert.assertFalse(testRan); + testRan = true; + Assert.assertTrue(beforeRan); + Assert.assertFalse(afterRan); + } +} \ No newline at end of file diff --git a/frameworks/projects/RoyaleUnit/src/test/royale/tests/BeforeClassAndAfterClassTests.as b/frameworks/projects/RoyaleUnit/src/test/royale/tests/BeforeClassAndAfterClassTests.as new file mode 100644 index 0000000..e963f18 --- /dev/null +++ b/frameworks/projects/RoyaleUnit/src/test/royale/tests/BeforeClassAndAfterClassTests.as @@ -0,0 +1,212 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package tests +{ + import org.apache.royale.test.Assert; + import org.apache.royale.test.runners.MetadataRunner; + import org.apache.royale.test.runners.notification.RunNotifier; + + public class BeforeClassAndAfterClassTests + { + private var _runner:MetadataRunner; + + [Before] + public function setUp():void + { + beforeClassRan = false; + afterClassRan = false; + test1Ran = false; + test2Ran = false; + } + + [After] + public function tearDown():void + { + beforeClassRan = false; + afterClassRan = false; + test1Ran = false; + test2Ran = false; + _runner = null; + } + + [Test] + public function testBeforeClass():void + { + _runner = new MetadataRunner(BeforeClassFixture); + + Assert.assertFalse(beforeClassRan); + Assert.assertFalse(afterClassRan); + Assert.assertFalse(test1Ran); + Assert.assertFalse(test2Ran); + + _runner.run(new RunNotifier()); + + Assert.assertTrue(beforeClassRan); + Assert.assertFalse(afterClassRan); + Assert.assertTrue(test1Ran); + Assert.assertTrue(test2Ran); + } + + [Test] + public function testAfterClass():void + { + _runner = new MetadataRunner(AfterClassFixture); + + Assert.assertFalse(beforeClassRan); + Assert.assertFalse(afterClassRan); + Assert.assertFalse(test1Ran); + Assert.assertFalse(test2Ran); + + _runner.run(new RunNotifier()); + + Assert.assertFalse(beforeClassRan); + Assert.assertTrue(afterClassRan); + Assert.assertTrue(test1Ran); + Assert.assertTrue(test2Ran); + } + + [Test] + public function testBeforeClassAndAfterClass():void + { + _runner = new MetadataRunner(BeforeClassAndAfterClassFixture); + + Assert.assertFalse(beforeClassRan); + Assert.assertFalse(afterClassRan); + Assert.assertFalse(test1Ran); + Assert.assertFalse(test2Ran); + + _runner.run(new RunNotifier()); + + Assert.assertTrue(beforeClassRan); + Assert.assertTrue(afterClassRan); + Assert.assertTrue(test1Ran); + Assert.assertTrue(test2Ran); + } + } +} + +import org.apache.royale.test.Assert; + +var beforeClassRan:Boolean = false; +var afterClassRan:Boolean = false; +var test1Ran:Boolean = false; +var test2Ran:Boolean = false; + +class BeforeClassFixture +{ + [BeforeClass] + public function beforeClass():void + { + Assert.assertFalse(beforeClassRan); + beforeClassRan = true; + Assert.assertFalse(test1Ran); + Assert.assertFalse(test2Ran); + Assert.assertFalse(afterClassRan); + } + + [Test] + public function test1():void + { + Assert.assertFalse(test1Ran); + test1Ran = true; + Assert.assertTrue(beforeClassRan); + Assert.assertFalse(afterClassRan); + } + + [Test] + public function test2():void + { + Assert.assertFalse(test2Ran); + test2Ran = true; + Assert.assertTrue(beforeClassRan); + Assert.assertFalse(afterClassRan); + } +} + +class AfterClassFixture +{ + [AfterClass] + public function afterClass():void + { + Assert.assertFalse(afterClassRan); + afterClassRan = true; + Assert.assertFalse(beforeClassRan); + Assert.assertTrue(test1Ran); + Assert.assertTrue(test2Ran); + } + + [Test] + public function test1():void + { + Assert.assertFalse(test1Ran); + test1Ran = true; + Assert.assertFalse(beforeClassRan); + Assert.assertFalse(afterClassRan); + } + + [Test] + public function test2():void + { + Assert.assertFalse(test2Ran); + test2Ran = true; + Assert.assertFalse(beforeClassRan); + Assert.assertFalse(afterClassRan); + } +} + +class BeforeClassAndAfterClassFixture +{ + [BeforeClass] + public function beforeClass():void + { + Assert.assertFalse(beforeClassRan); + beforeClassRan = true; + Assert.assertFalse(test1Ran); + Assert.assertFalse(test2Ran); + Assert.assertFalse(afterClassRan); + } + + [AfterClass] + public function afterClass():void + { + Assert.assertFalse(afterClassRan); + afterClassRan = true; + Assert.assertTrue(beforeClassRan); + Assert.assertTrue(test1Ran); + Assert.assertTrue(test2Ran); + } + + [Test] + public function test1():void + { + Assert.assertFalse(test1Ran); + test1Ran = true; + Assert.assertTrue(beforeClassRan); + Assert.assertFalse(afterClassRan); + } + + [Test] + public function test2():void + { + Assert.assertFalse(test2Ran); + test2Ran = true; + Assert.assertTrue(beforeClassRan); + Assert.assertFalse(afterClassRan); + } +} \ No newline at end of file diff --git a/frameworks/projects/RoyaleUnit/src/test/royale/tests/IgnoreTests.as b/frameworks/projects/RoyaleUnit/src/test/royale/tests/IgnoreTests.as new file mode 100644 index 0000000..6e55ad2 --- /dev/null +++ b/frameworks/projects/RoyaleUnit/src/test/royale/tests/IgnoreTests.as @@ -0,0 +1,108 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package tests +{ + import org.apache.royale.test.Assert; + import org.apache.royale.test.runners.MetadataRunner; + import org.apache.royale.test.runners.notification.RunNotifier; + + public class IgnoreTests + { + private var _runner:MetadataRunner; + + [Before] + public function setUp():void + { + test1Ran = false; + test2Ran = false; + } + + [After] + public function tearDown():void + { + test1Ran = false; + test2Ran = false; + _runner = null; + } + + [Test] + public function testIgnore():void + { + _runner = new MetadataRunner(IgnoreFixture); + + Assert.assertFalse(test1Ran); + Assert.assertFalse(test2Ran); + + _runner.run(new RunNotifier()); + + Assert.assertTrue(test1Ran); + Assert.assertFalse(test2Ran); + } + + [Test] + public function testIgnoreAll():void + { + _runner = new MetadataRunner(IgnoreAllFixture); + + Assert.assertFalse(test1Ran); + Assert.assertFalse(test2Ran); + + _runner.run(new RunNotifier()); + + Assert.assertFalse(test1Ran); + Assert.assertFalse(test2Ran); + } + } +} + +var test1Ran:Boolean = false; +var test2Ran:Boolean = false; + +class IgnoreFixture +{ + [Test] + public function test1():void + { + test1Ran = true; + } + + [Ignore] + [Test] + public function test2():void + { + test2Ran = true; + } +} + +class IgnoreAllFixture +{ + [Ignore] + [Test] + public function test1():void + { + test1Ran = true; + } + + [Ignore] + [Test] + public function test2():void + { + test2Ran = true; + } +} \ No newline at end of file diff --git a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as b/frameworks/projects/RoyaleUnit/src/test/royale/tests/RoyaleUnitSuite.as similarity index 75% copy from frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as copy to frameworks/projects/RoyaleUnit/src/test/royale/tests/RoyaleUnitSuite.as index 4b0ecfc..d5d320c 100644 --- a/frameworks/projects/Basic/src/test/royale/flexUnitTests/DataGridColumnTester.as +++ b/frameworks/projects/RoyaleUnit/src/test/royale/tests/RoyaleUnitSuite.as @@ -16,12 +16,15 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package flexUnitTests +package tests { - [Suite] - [RunWith("org.flexunit.runners.Suite")] - public class DataGridColumnTester - { - public var dataGridColumnTest:DataGridColumnTest; - } -} + [Suite] + [RunWith("org.apache.royale.test.runners.SuiteRunner")] + public class RoyaleUnitSuite + { + public var beforeAndAfterTests:BeforeAndAfterTests; + public var beforeClassAndAfterClassTests:BeforeClassAndAfterClassTests; + public var ignoreTests:IgnoreTests; + public var scopeTests:ScopeTests; + } +} \ No newline at end of file diff --git a/frameworks/projects/Testing/src/test/royale/tests/ScopeTests.as b/frameworks/projects/RoyaleUnit/src/test/royale/tests/ScopeTests.as similarity index 85% rename from frameworks/projects/Testing/src/test/royale/tests/ScopeTests.as rename to frameworks/projects/RoyaleUnit/src/test/royale/tests/ScopeTests.as index 8a318f3..0b64028 100644 --- a/frameworks/projects/Testing/src/test/royale/tests/ScopeTests.as +++ b/frameworks/projects/RoyaleUnit/src/test/royale/tests/ScopeTests.as @@ -22,26 +22,26 @@ package tests public class ScopeTests { - private var _value:String = "hello"; + private var _value:String = "ScopeTests hello"; [Before] public function prepare():void { - Assert.strictEqual(this._value, "hello", + Assert.assertStrictlyEquals(this._value, "ScopeTests hello", "Function marked with [Before] metadata called with incorrect scope."); } [After] public function cleanup():void { - Assert.strictEqual(this._value, "hello", + Assert.assertStrictlyEquals(this._value, "ScopeTests hello", "Function marked with [After] metadata called with incorrect scope."); } [Test] public function testScope():void { - Assert.strictEqual(this._value, "hello", + Assert.assertStrictlyEquals(this._value, "ScopeTests hello", "Function marked with [Test] metadata called with incorrect scope."); } } diff --git a/frameworks/projects/SparkRoyale/build.xml b/frameworks/projects/SparkRoyale/build.xml index 1f404dd..2cd6c21 100644 --- a/frameworks/projects/SparkRoyale/build.xml +++ b/frameworks/projects/SparkRoyale/build.xml @@ -52,7 +52,7 @@
- + diff --git a/frameworks/projects/Storage/build.xml b/frameworks/projects/Storage/build.xml index 367f6b0..6b8341a 100644 --- a/frameworks/projects/Storage/build.xml +++ b/frameworks/projects/Storage/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/TLF/build.xml b/frameworks/projects/TLF/build.xml index 28d9ec8..5436063 100644 --- a/frameworks/projects/TLF/build.xml +++ b/frameworks/projects/TLF/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/Testing/asconfig.json b/frameworks/projects/Testing/asconfig.json deleted file mode 100644 index 191737b..0000000 --- a/frameworks/projects/Testing/asconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "config": "royale", - "type": "lib", - "compilerOptions": { - "debug": true, - "targets": [ - "SWF", - "JSRoyale" - ], - "include-classes": [ - "TestingClasses" - ], - "include-sources": [ - "src/main/royale" - ], - "library-path": [ - "../../../../flex-flexunit/FlexUnit4/target/flexunit-4.3.0-20140410-as3_4.12.0.swc" - ], - "output": "target/Testing.swc" - } -} diff --git a/frameworks/projects/Testing/build.xml b/frameworks/projects/Testing/build.xml deleted file mode 100644 index 0b2e7d0..0000000 --- a/frameworks/projects/Testing/build.xml +++ /dev/null @@ -1,160 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/frameworks/projects/Testing/src/main/resources/basic-manifest.xml b/frameworks/projects/Testing/src/main/resources/basic-manifest.xml deleted file mode 100644 index aa138a3..0000000 --- a/frameworks/projects/Testing/src/main/resources/basic-manifest.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - diff --git a/frameworks/projects/Testing/src/main/resources/defaults.css b/frameworks/projects/Testing/src/main/resources/defaults.css deleted file mode 100644 index 2dbeea7..0000000 --- a/frameworks/projects/Testing/src/main/resources/defaults.css +++ /dev/null @@ -1,23 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -@namespace "library://ns.apache.org/royale/basic"; -@namespace svg "library://ns.apache.org/royale/svg"; - - diff --git a/frameworks/projects/Testing/src/main/royale/TestingClasses.as b/frameworks/projects/Testing/src/main/royale/TestingClasses.as deleted file mode 100644 index f1b2449..0000000 --- a/frameworks/projects/Testing/src/main/royale/TestingClasses.as +++ /dev/null @@ -1,46 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package -{ - -/** - * @private - * This class is used to link additional classes into rpc.swc - * beyond those that are found by dependency analysis starting - * from the classes specified in manifest.xml. - */ -internal class TestingClasses -{ - import org.apache.royale.test.Assert; Assert; - import org.apache.royale.test.asserts.assertDefined; assertDefined; - import org.apache.royale.test.asserts.assertEquals; assertEquals; - import org.apache.royale.test.asserts.assertFalse; assertFalse; - import org.apache.royale.test.asserts.assertNotNull; assertNotNull; - import org.apache.royale.test.asserts.assertNull; assertNull; - import org.apache.royale.test.asserts.assertStrictlyEquals; assertStrictlyEquals; - import org.apache.royale.test.asserts.assertTrue; assertTrue; - import org.apache.royale.test.asserts.assertUndefined; assertUndefined; - import org.apache.royale.test.asserts.fail; fail; - - import org.apache.royale.test.TraceListener; TraceListener; - -} - -} - diff --git a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/Assert.as b/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/Assert.as deleted file mode 100644 index 5677b3b..0000000 --- a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/Assert.as +++ /dev/null @@ -1,156 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.royale.test -{ - import org.apache.royale.test.AssertionError; - - public class Assert - { - public static function strictEqual(actual:*, expected:*, message:String = null):void - { - if(actual === expected) - { - return; - } - throw new AssertionError(message); - } - - public static function notStrictEqual(actual:*, expected:*, message:String = null):void - { - if(actual !== expected) - { - return; - } - throw new AssertionError(message); - } - - public static function equal(actual:*, expected:*, message:String = null):void - { - if(actual == expected) - { - return; - } - throw new AssertionError(message); - } - - public static function notEqual(actual:*, expected:*, message:String = null):void - { - if(actual != expected) - { - return; - } - throw new AssertionError(message); - } - - public static function true(actual:*, message:String = null):void - { - if(actual == true) - { - return; - } - throw new AssertionError(message); - } - - public static function false(actual:*, message:String = null):void - { - if(actual == false) - { - return; - } - throw new AssertionError(message); - } - - public static function null(actual:*, message:String = null):void - { - if(actual == null) - { - return; - } - throw new AssertionError(message); - } - - public static function notNull(actual:*, message:String = null):void - { - if(actual != null) - { - return; - } - throw new AssertionError(message); - } - - public static function nullStrict(actual:*, message:String = null):void - { - if(actual === null) - { - return; - } - throw new AssertionError(message); - } - - public static function notNullStrict(actual:*, message:String = null):void - { - if(actual !== null) - { - return; - } - throw new AssertionError(message); - } - - public static function undefined(actual:*, message:String = null):void - { - if(actual === undefined) - { - return; - } - throw new AssertionError(message); - } - - public static function defined(actual:*, message:String = null):void - { - if(actual !== undefined) - { - return; - } - throw new AssertionError(message); - } - - public static function NaN(actual:*, message:String = null):void - { - if(isNaN(actual)) - { - return; - } - throw new AssertionError(message); - } - - public static function notNaN(actual:*, message:String = null):void - { - if(!isNaN(actual)) - { - return; - } - throw new AssertionError(message); - } - - public static function fail(message:String):void - { - throw new AssertionError(message); - } - } -} \ No newline at end of file diff --git a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/AssertionError.as b/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/AssertionError.as deleted file mode 100644 index 581bfeb..0000000 --- a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/AssertionError.as +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.royale.test -{ - public class AssertionError extends Error - { - public function AssertionError(message:String) - { - this.message = message; - COMPILE::JS - { - this.stack = (new Error()).stack; - } - } - } -} \ No newline at end of file diff --git a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/TestEvent.as b/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/TestEvent.as deleted file mode 100644 index c2b567b..0000000 --- a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/TestEvent.as +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.royale.test -{ - public class TestEvent - { - public static const TEST_RUN_START:String = "testRunStart"; - public static const TEST_RUN_COMPLETE:String = "testRunComplete"; - public static const TEST_RUN_FAIL:String = "testRunFail"; - public static const TEST_START:String = "testStart"; - public static const TEST_COMPLETE:String = "testComplete"; - public static const TEST_FAIL:String = "testFail"; - - public function TestEvent(type:String, testName:String = null, error:Error = null) - { - this._type = type; - this._testName = testName; - this._error = error; - } - - private var _type:String; - - public function get type():String - { - return this._type; - } - - private var _testName:String; - - public function get testName():String - { - return this._testName; - } - - private var _error:Error; - - public function get error():Error - { - return this._error; - } - } -} \ No newline at end of file diff --git a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/TestRunner.as b/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/TestRunner.as deleted file mode 100644 index 05954a3..0000000 --- a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/TestRunner.as +++ /dev/null @@ -1,354 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.royale.test -{ - import org.apache.royale.test.AssertionError; - import org.apache.royale.test.TestEvent; - - /** - * Dispatched at the start of an individual test. - * - * @eventType nextgenas.unit.events.TestEvent.TEST_START - * - * @see #event:testComplete - * @see #event:testFail - */ - [Event(name="testStart",type="nextgenas.unit.events.TestEvent")] - - /** - * Dispatched when an individual test completes successfully. If the test - * fails, TestEvent.TEST_FAIL will be dispatched instead. - * - * @eventType nextgenas.unit.events.TestEvent.TEST_COMPLETE - * - * @see #event:testFail - */ - [Event(name="testComplete",type="nextgenas.unit.events.TestEvent")] - - /** - * Dispatched when an individual test fails. - * - * @eventType nextgenas.unit.events.TestEvent.TEST_FAIL - */ - [Event(name="testFail",type="nextgenas.unit.events.TestEvent")] - - /** - * Dispatched at the start of all tests. - * - * @eventType nextgenas.unit.events.TestEvent.TEST_RUN_START - * - * @see #event:testRunComplete - * @see #event:testRunFail - */ - [Event(name="testRunStart",type="nextgenas.unit.events.TestEvent")] - - /** - * Dispatched when all tests complete successfully. If any tests fail, - * TestEvent.TEST_RUN_FAIL will be dispatched instead. - * - * @eventType nextgenas.unit.events.TestEvent.TEST_RUN_COMPLETE - * - * @see #event:testRunFail - */ - [Event(name="testRunComplete",type="nextgenas.unit.events.TestEvent")] - - /** - * Dispatched when all tests have been run, but some failed. - * - * @eventType nextgenas.unit.events.TestEvent.TEST_RUN_FAIL - */ - [Event(name="testRunFail",type="nextgenas.unit.events.TestEvent")] - - /** - * - */ - public class TestRunner - { - /** - * Constructor. - */ - public function TestRunner() - { - - } - - /** - * @private - */ - private var _failCount:int = 0; - - /** - * The total number of tests that have failed. - * - * @see #testCount - */ - public function get failCount():int - { - return this._failCount; - } - - /** - * @private - */ - private var _testCount:int = 0; - - /** - * The number of tests that have been run. - * - * @see #failCount - */ - public function get testCount():int - { - return this._testCount; - } - - /** - * @private - */ - private var _listeners:Object; - - /** - * - */ - public function addEventListener(type:String, listener:Function):void - { - if(!this._listeners) - { - this._listeners = {}; - } - var listenersOfType:Vector.; - if(type in this._listeners) - { - listenersOfType = this._listeners[type] as Vector. - } - else - { - listenersOfType = new []; - this._listeners[type] = listenersOfType; - } - if(listenersOfType.indexOf(listener) >= 0) - { - //the event is already added - return; - } - listenersOfType[listenersOfType.length] = listener; - } - - /** - * - */ - public function removeEventListener(type:String, listener:Function):void - { - if(!this._listeners) - { - return; - } - if(!(type in this._listeners)) - { - return; - } - var listenersOfType:Vector. = this._listeners[type] as Vector.; - var index:int = listenersOfType.indexOf(listener); - if(index < 0) - { - return; - } - //if this is called while the event is being dispatched, we don't - //want to modify the original array - listenersOfType = listenersOfType.slice(); - this._listeners[type] = listenersOfType; - if(index == 0) - { - listenersOfType.shift(); - } - else if(index == listenersOfType.length - 1) - { - listenersOfType.pop(); - } - else - { - listenersOfType.splice(index, 1); - } - } - - /** - * @private - */ - private function dispatchEvent(event:TestEvent):void - { - if(!this._listeners) - { - return; - } - var type:String = event.type; - if(!(type in this._listeners)) - { - return; - } - var listenersOfType:Vector. = this._listeners[type] as Vector.; - var listenerCount:int = listenersOfType.length; - for(var i:int = 0; i < listenerCount; i++) - { - var listener:Function = listenersOfType[i]; - listener(event); - } - } - - /** - * Runs all tests defined on the specified classes. - */ - public function run(tests:Vector.):void - { - this._testCount = 0; - this._failCount = 0; - this.dispatchEvent(new TestEvent(TestEvent.TEST_RUN_START)); - var classCount:int = tests.length; - for(var i:int = 0; i < classCount; i++) - { - var testClass:Class = tests[i]; - var test:Object = new testClass(); - this.runTestMethods(test); - } - if(this._failCount > 0) - { - this.dispatchEvent(new TestEvent(TestEvent.TEST_RUN_FAIL)); - } - else - { - this.dispatchEvent(new TestEvent(TestEvent.TEST_RUN_COMPLETE)); - } - } - - /** - * @private - */ - private function runTestMethods(target:Object):void - { - var before:Function = collectMethodWithMetadataTag(target, "Before"); - var after:Function = collectMethodWithMetadataTag(target, "After"); - var tests:Vector. = collectTests(target); - var testCount:int = tests.length; - if(testCount == 0) - { - throw new Error("No methods found with [Test] metadata. Did you forget to include the -keep-as3-metadata compiler option?") - } - for(var i:int = 0; i < testCount; i++) - { - try - { - var test:TestInfo = tests[i]; - this.dispatchEvent(new TestEvent(TestEvent.TEST_START, test.name)); - if(before != null) - { - before.apply(target); - } - test.reference.apply(target); - if(after != null) - { - after.apply(target); - } - this._testCount++; - this.dispatchEvent(new TestEvent(TestEvent.TEST_COMPLETE, test.name)); - } - catch(error:Error) - { - this._testCount++; - this._failCount++; - this.dispatchEvent(new TestEvent(TestEvent.TEST_FAIL, test.name, error)); - } - } - } - - /** - * @private - */ - private function collectMethodWithMetadataTag(target:Object, tagName:String):Function - { - var reflection:Object = target["ROYALE_REFLECTION_INFO"](); - var methods:Object = reflection.methods(); - for(var methodName:String in methods) - { - var method:Object = methods[methodName]; - if("metadata" in method) - { - var declaredBy:String = method.declaredBy; - var tags:Array = method.metadata(); - var tagsCount:int = tags.length; - for(var i:int = 0; i < tagsCount; i++) - { - var tag:Object = tags[i]; - var methodTagName:String = tag.name; - if(methodTagName == tagName) - { - return target[methodName]; - } - } - } - } - return null; - } - - /** - * @private - */ - private function collectTests(target:Object):Vector. - { - var tests:Vector. = new []; - var reflection:Object = target["ROYALE_REFLECTION_INFO"](); - var methods:Object = reflection.methods(); - for(var methodName:String in methods) - { - var method:Object = methods[methodName]; - if("metadata" in method) - { - var declaredBy:String = method.declaredBy; - var tags:Array = method.metadata(); - var tagsCount:int = tags.length; - for(var i:int = 0; i < tagsCount; i++) - { - var tag:Object = tags[i]; - var tagName:String = tag.name; - if(tagName == "Test") - { - var reference:Function = target[methodName]; - var info:TestInfo = new TestInfo(declaredBy + "." + methodName, reference); - tests.push(info); - } - } - } - } - return tests; - } - } -} - -/** - * @royalesuppresspublicvarwarning - */ -class TestInfo -{ - public function TestInfo(name:String, reference:Function) - { - this.name = name; - this.reference = reference; - } - - public var name:String; - public var reference:Function; -} \ No newline at end of file diff --git a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/TraceListener.as b/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/TraceListener.as deleted file mode 100644 index b3f8b7b..0000000 --- a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/TraceListener.as +++ /dev/null @@ -1,144 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.royale.test -{ - import org.apache.royale.test.TestRunner; - import org.apache.royale.test.TestEvent; - import org.apache.royale.test.AssertionError; - - public class TraceListener - { - public function TraceListener(runner:TestRunner) - { - runner.addEventListener(TestEvent.TEST_RUN_START, testRunStartHandler); - runner.addEventListener(TestEvent.TEST_RUN_COMPLETE, testRunCompleteHandler); - runner.addEventListener(TestEvent.TEST_RUN_FAIL, testRunFailHandler); - runner.addEventListener(TestEvent.TEST_START, testStartHandler); - runner.addEventListener(TestEvent.TEST_COMPLETE, testCompleteHandler); - runner.addEventListener(TestEvent.TEST_FAIL, testFailHandler); - } - - private var _startTime:Number; - private var _passCount:int; - private var _failCount:int; - private var _failures:Vector.; - - private function finish():void - { - var totalTime:Number = ((new Date()).getTime() - this._startTime) / 1000; - trace("Time: " + totalTime); - - var failureMessageCount:int = this._failures.length; - if(failureMessageCount > 0) - { - if(this._failCount == 1) - { - trace("There was 1 failure:"); - } - else - { - trace("There were " + this._failCount + " failures:"); - } - for(var i:int = 0; i < failureMessageCount; i++) - { - trace((i + 1) + " " + this._failures[i]); - } - } - - var totalCount:int = this._passCount + this._failCount; - var testString:String = "tests"; - if(totalCount == 1) - { - testString = "test"; - } - - if(this._failCount > 0) - { - var failureString:String = "failures"; - if(this._failCount == 1) - { - failureString = "failure"; - } - trace("FAILURE (" + totalCount + " " + testString + ", " + this._failCount + " " + failureString + ")"); - } - else - { - trace("OK (" + this._passCount + " " + testString + ")"); - } - } - - private function testRunStartHandler(event:TestEvent):void - { - this._startTime = (new Date()).getTime(); - this._passCount = 0; - this._failCount = 0; - this._failures = new []; - } - - private function testRunFailHandler(event:TestEvent):void - { - finish(); - } - - private function testRunCompleteHandler(event:TestEvent):void - { - finish(); - } - - private function testStartHandler(event:TestEvent):void - { - trace(event.testName + " ."); - } - - private function testCompleteHandler(event:TestEvent):void - { - this._passCount++; - } - - private function testFailHandler(event:TestEvent):void - { - this._failCount++; - var error:Error = event.error; - if(error is AssertionError) - { - trace(event.testName + " F"); - } - else //some other error - { - trace(event.testName + " E"); - } - - var message:String = event.testName; - if(error is Error) - { - var errorMessage:String = error.message; - if(errorMessage) - { - message += " " + errorMessage; - } - message += " " + error.stack; - } - else //fall back to the normal toString() - { - message += " " + error; - } - this._failures.push(message); - } - } -} \ No newline at end of file diff --git a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertDefined.as b/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertDefined.as deleted file mode 100644 index daa5952..0000000 --- a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertDefined.as +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.royale.test.asserts { - - COMPILE::SWF - { - import org.flexunit.Assert; - } - - COMPILE::JS - { - import org.apache.royale.test.Assert; - } - - /** - * - * Accepts an argument of type Object. - * If two arguments are passed the second argument will be used as the error message. - * - * assertTrue( String, Boolean ); - * assertTrue( Boolean ); - * - * @see org.flexunit.Assert assertTrue; - */ - public function assertDefined(actual:*, message:String = null):void { - COMPILE::SWF - { - if(message) - Assert.assertTrue(message, actual !== undefined); - else - Assert.assertTrue(actual); - } - COMPILE::JS - { - Assert.defined(actual, message); - } - } -} \ No newline at end of file diff --git a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertEquals.as b/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertEquals.as deleted file mode 100644 index 1d67f6d..0000000 --- a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertEquals.as +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.royale.test.asserts { - COMPILE::SWF - { - import org.flexunit.Assert; - } - - COMPILE::JS - { - import org.apache.royale.test.Assert; - } - - /** - * Alias for org.flexunit.Assert assertEquals method - * - * @param rest - * Must be passed at least 2 arguments to compare for equality. - * If three arguments are passed, the third argument will be used as the error message. - * - * assertEquals( String, Object, Object ); - * assertEquals( Object, Object ); - * - * @see org.flexunit.Assert assertEquals - */ - public function assertEquals(actual:*, expected:*, message:String = null):void { - COMPILE::SWF - { - if(message) - Assert.assertEquals(message, actual, expected); - else - Assert.assertEquals(actual, expected); - } - COMPILE::JS - { - Assert.equal(actual, expected, message); - } - } -} \ No newline at end of file diff --git a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertFalse.as b/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertFalse.as deleted file mode 100644 index 155bb9d..0000000 --- a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertFalse.as +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.royale.test.asserts { - COMPILE::SWF - { - import org.flexunit.Assert; - } - - COMPILE::JS - { - import org.apache.royale.test.Assert; - } - - /** - * Alias for org.flexunit.Assert assertFalse method - * - * Accepts an argument of type Boolean. - * If two arguments are passed the second argument will be used as the error message. - * - * assertFalse( Boolean, String ); - * assertFalse( Boolean ); - * - * @see org.flexunit.Assert assertFalse - */ - - public function assertFalse(actual:*, message:String = null):void { - - COMPILE::SWF - { - if(message) - Assert.assertFalse(message, actual); - else - Assert.assertFalse(actual); - } - COMPILE::JS - { - Assert.false(actual, message); - } - - } -} \ No newline at end of file diff --git a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertNotNull.as b/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertNotNull.as deleted file mode 100644 index f51e9a7..0000000 --- a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertNotNull.as +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.royale.test.asserts { - COMPILE::SWF - { - import org.flexunit.Assert; - } - - COMPILE::JS - { - import org.apache.royale.test.Assert; - } - - /** - * Alias for org.flexunit.Assert assertNotNull method - * - * @param rest - * Accepts an argument of type Object. - * If two arguments are passed the first argument must be a String - * and will be used as the error message. - * - * assertNotNull( String, Object ); - * assertNotNull( Object ); - * - * @see org.flexunit.Assert assertNotNull - */ - public function assertNotNull(actual:*, message:String = null):void { - COMPILE::SWF - { - if(message) - Assert.assertNotNull(message, actual); - else - Assert.assertNotNull(actual); - } - COMPILE::JS - { - Assert.notNull(actual, message); - } - } -} \ No newline at end of file diff --git a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertNull.as b/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertNull.as deleted file mode 100644 index 864152b..0000000 --- a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertNull.as +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.royale.test.asserts { - - COMPILE::SWF - { - import org.flexunit.Assert; - } - - COMPILE::JS - { - import org.apache.royale.test.Assert; - } - - /** - * Alias for org.flexunit.Assert assertNull method - * - * Accepts an argument of type Object. - * If two arguments are passed the second argument will be used as the error message. - * - * assertNull( Object, String ); - * assertNull( Object ); - * - * @see org.flexunit.Assert assertNull - */ - public function assertNull(actual:*, message:String = null):void { - COMPILE::SWF - { - if(message) - Assert.assertNull(message, actual); - else - Assert.assertNull(actual); - } - COMPILE::JS - { - Assert.null(actual, message); - } - } -} \ No newline at end of file diff --git a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertStrictlyEquals.as b/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertStrictlyEquals.as deleted file mode 100644 index a693255..0000000 --- a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertStrictlyEquals.as +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.royale.test.asserts -{ - COMPILE::SWF - { - import org.flexunit.Assert; - } - - COMPILE::JS - { - import org.apache.royale.test.Assert; - } - - /** - * Alias for org.flexunit.Assert assertStrictlyEquals method - * - * @param rest - * Must be passed at least 2 arguments of type Object to compare for strict equality. - * If three arguments are passed, the last argument will be used as the error message. - * - * assertStrictlyEquals( Object, Object, String ); - * assertStrictlyEquals( Object, Object ); - * - * @see org.flexunit.Assert assertStrictlyEquals - */ - public function assertStrictlyEquals(actual:*, expected:*, message:String = null):void { - COMPILE::SWF - { - if(message) - Assert.assertStrictlyEquals(message, actual, expected); - else - Assert.assertStrictlyEquals(actual, expected); - } - COMPILE::JS - { - Assert.strictEqual(actual, expected, message); - } - } -} \ No newline at end of file diff --git a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertTrue.as b/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertTrue.as deleted file mode 100644 index 9c368d9..0000000 --- a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertTrue.as +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.royale.test.asserts { - - COMPILE::SWF - { - import org.flexunit.Assert; - } - - COMPILE::JS - { - import org.apache.royale.test.Assert; - } - - /** - * Alias for org.flexunit.Assert assertTrue method - * - * @param rest - * Accepts an argument of type Boolean. - * If two arguments are passed the second argument will be used as the error message. - * - * assertTrue( String, Boolean ); - * assertTrue( Boolean ); - * - * @see org.flexunit.Assert assertTrue; - */ - public function assertTrue(actual:*, message:String = null):void { - COMPILE::SWF - { - if(message) - Assert.assertTrue(message, actual); - else - Assert.assertTrue(actual); - } - COMPILE::JS - { - Assert.true(actual, message); - } - } -} \ No newline at end of file diff --git a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertUndefined.as b/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertUndefined.as deleted file mode 100644 index 1d32997..0000000 --- a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertUndefined.as +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.royale.test.asserts { - - COMPILE::SWF - { - import org.flexunit.Assert; - } - - COMPILE::JS - { - import org.apache.royale.test.Assert; - } - - /** - * Alias for org.flexunit.Assert assertTrue method - * - * @param rest - * Accepts an argument of type Boolean. - * If two arguments are passed the second argument will be used as the error message. - * - * assertTrue( String, Boolean ); - * assertTrue( Boolean ); - * - * @see org.flexunit.Assert assertTrue; - */ - public function assertUndefined(actual:*, message:String = null):void { - COMPILE::SWF - { - if(message) - Assert.assertTrue(message, actual === undefined); - else - Assert.assertTrue(actual); - } - COMPILE::JS - { - Assert.undefined(actual, message); - } - } -} \ No newline at end of file diff --git a/frameworks/projects/Testing/src/test/royale/asconfig.json b/frameworks/projects/Testing/src/test/royale/asconfig.json deleted file mode 100644 index 3d70c1b..0000000 --- a/frameworks/projects/Testing/src/test/royale/asconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "config": "node", - "compilerOptions": { - "debug": true, - "keep-as3-metadata": [ - "Test", - "Before", - "After" - ], - "source-map": true, - "source-path": [ - "source", - "../source" - ] - }, - "files":[ - "NodeTests.as" - ] -} \ No newline at end of file diff --git a/frameworks/projects/Testing/src/test/royale/build.xml b/frameworks/projects/Testing/src/test/royale/build.xml deleted file mode 100644 index ca13ed3..0000000 --- a/frameworks/projects/Testing/src/test/royale/build.xml +++ /dev/null @@ -1,165 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/frameworks/projects/Text/build.xml b/frameworks/projects/Text/build.xml index a443deb..5c0ffd9 100644 --- a/frameworks/projects/Text/build.xml +++ b/frameworks/projects/Text/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/XML/build.xml b/frameworks/projects/XML/build.xml index 62a989b..29475b9 100644 --- a/frameworks/projects/XML/build.xml +++ b/frameworks/projects/XML/build.xml @@ -52,7 +52,7 @@ - + diff --git a/frameworks/projects/pom.xml b/frameworks/projects/pom.xml index 6fcb064..df0989e 100644 --- a/frameworks/projects/pom.xml +++ b/frameworks/projects/pom.xml @@ -71,7 +71,7 @@ brokenmodules - Testing + RoyaleUnit diff --git a/frameworks/royale-config-template.xml b/frameworks/royale-config-template.xml index 84bb3a2..6eb1195 100644 --- a/frameworks/royale-config-template.xml +++ b/frameworks/royale-config-template.xml @@ -118,9 +118,9 @@ libs/Network.swc libs/Reflection.swc libs/RoyaleSite.swc + libs/RoyaleUnit.swc libs/Storage.swc libs/TLF.swc - libs/Testing.swc libs/Text.swc libs/XML.swc {playerglobalHome}/{targetPlayerMajorVersion}.{targetPlayerMinorVersion} @@ -154,9 +154,9 @@ js/libs/NetworkJS.swc js/libs/ReflectionJS.swc js/libs/RoyaleSiteJS.swc + js/libs/RoyaleUnitJS.swc js/libs/StorageJS.swc js/libs/TLFJS.swc - js/libs/TestingJS.swc js/libs/TextJS.swc js/libs/XMLJS.swc