Hi Ray and Michael,

that's the setup I'm using to, but I want to clarify some things:

@Ray:

* you don't need to use As2lib Configuration. You may also just use the 
TestSuiteFactory to collect test cases and run the collected test cases 
manually in a simple static main method.
* Test classes don't need to be suffixed "Test". The TestSuiteFactory 
collects all test cases which extend the TestCase class.
* You don't need to use the TestSuiteFactory. You may also just 
instantiate and invoke a test case manually and create TestSuite 
subclasses for modules and/or packages.

@Michael:

MtascApplication instantiates main.Mtasc and invokes its init method. 
Which then in turn uses the UnitTestExecution process. This process 
collects all test cases which are compiled into the SWF and extend the 
TestCase class. It then executes the collected test cases and writes out 
the results via the supplied listener, for example the 
XmlScoketTestListener. The com.simonwacker.MyTest case is included in 
the swf by referencing it; you may also include it in the build.xml by 
specifying it as source file for example in a srcset-tag.

The problem is that no data is sent to the server. I just realized that 
I built the example with the current SVN version and not release 0.9.3. 
In this release As2lib Configuration is slightly different and 
UnitTestExecution does not support custom listeners. Either check-out 
the latest As2lib version from the SVN repository or use the following 
init-method in the main.Mtasc class:

public static function init(root:MovieClip):Void {
    var factory:TestSuiteFactory = new TestSuiteFactory();
    var testSuite:TestSuite = factory.collectAllTestCases();
    testSuite.addListener(new XmlSocketTestListener());
    testSuite.run();
}


Greetings,
Simon

Ray Chuan wrote:

>Hi,
>I understand your predicament, recently I was experimenting with the
>as2lib unit test framework.
>
>To perform unit tests, you need
>- unit test "centre" which contains main entry point, if you're using
>mtasc, and extend org.as2lib.app.conf.AbstractConfiguration;
>- test files which MUST be suffixed by "Test", and extend
>org.as2lib.test.unit.TestCase.
>
>My test "centre" looks like this:
>
>--------------
>/* See LICENSE for copyright and terms of use */
>
>import org.as2lib.app.conf.AbstractConfiguration;
>import org.as2lib.app.conf.UnitTestExecution;
>import org.as2lib.test.unit.XmlSocketTestListener;
>
>/**
> * @author Tay Ray Chuan
> */
>
>class com.foo.test.unit.ProjectTests extends AbstractConfiguration {
>       public function init():Void {
>               initProcess(new UnitTestExecution(new XmlSocketTestListener()));
>       }
>
>       public function setReferences():Void {
>               use(com.foo.test.unit.EnvTest);
>               use(com.foo.test.unit.EsotericTest);
>               use(com.foo.test.unit.VeryLongWindedTest);
>       }
>
>       public static function main():Void {
>               var inst:ProjectTests = new ProjectTests();
>               inst.init();
>       }
>}
>--------------
>
>On 7/11/06, Michael Forrest <[EMAIL PROTECTED]> wrote:
>  
>
>>
>>
>>Right... I'm looking at the unit test sample included in as2ant.
>>
>>
>>
>>From what I can tell, the meat of the sample is contained here:
>>
>>
>>
>><target name="sample" description="runs unit tests">
>>
>><mtasc
>>src="${as2lib.dir}/org/as2lib/app/conf/MtascApplication.as"
>>      swf="${build.dir}/test.swf"
>>classpath="${as2lib.dir};${tests.dir};${flash.dir}"
>>
>>main="yes"
>>
>>header="10:10:10"
>>
>>mtasc="${mtasc.exe}"/>
>>
>><unittest swf="${build.dir}/test.swf" flashplayer="${flashplayer.exe}" />
>>
>></target>
>>
>>
>>
>>My understanding is that the MtascApplication class is a generic mtasc hook
>>to get a basic swf compiled that includes the ${tests.dir} classpath. I
>>can't really see what makes the XmlSocketPrinter work in this example –
>>although I have included it (through the ${flash.dir} property (it wouldn't
>>compile at all before that).
>>
>>
>>
>>From what I can see of the <unittest> task in java, it simply creates a
>>server to listen over a specified port to the launched swf.
>>
>>
>>
>>So in that example, how does the swf/unittest task know where the unit tests
>>are? (hint – they're under ${tests} in com.simonwacker.MyTest)
>>    
>>
>
>Yeah, you got it. as2lib searches for all classes that end with
>"Test", and runs methods like setUp, tearDown, test*, etc. For more
>information, refer to the documentation in
>org.as2lib.test.unit.TestCase.
>
>  
>
>>
>>
>>
>>-----Original Message-----
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
>>Behalf Of Michael Forrest
>> Sent: 10 July 2006 18:30
>> To: Open Source Flash Mailing List
>> Subject: Re: [osflash] as2ant unittest task - silence...
>>
>>
>>
>>Thanks for the quick reply -I'll have a look at this in the morning...
>>
>>
>>
>>-----Original Message-----
>>
>>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>>
>>On Behalf Of Chris Allen
>>
>>Sent: 10 July 2006 18:14
>>
>>To: Open Source Flash Mailing List
>>
>>Subject: Re: [osflash] as2ant unittest task - silence...
>>
>>
>>
>>On 7/10/06, Michael Forrest <[EMAIL PROTECTED]> wrote:
>>
>>    
>>
>>>I can't see any reference to TestRunner in the download I'm trying to
>>>      
>>>
>>>use (as2ant_2.0.zip). Is that for asunit? I thought the example used
>>>      
>>>
>>>as2lib, and that as2lib is a different engine to asunit...
>>>      
>>>
>>Hahaha! Yeah how many ways can we reuse the characters AS and the
>>
>>number 2? okay, so it is a bit confusing, and I made matters worse by
>>
>>not explaining more and actually not remembering exactly how it's
>>
>>setup.
>>
>>
>>
>>The file that you are looking for is in the as2ant_2.0.zip here:
>>
>>as2ant/flash/org/as2lib/test/unit/XmlSocketResultPrinter.as
>>
>>
>>
>>That's the result printer that you will need to call from your
>>
>>implementation of TestRunner. I have created one that looks like this:
>>
>>
>>
>>/**
>>
>> * @author Chris Allen [EMAIL PROTECTED]
>>
>> */
>>
>>
>>
>>import asunit.textui.TestRunner;
>>
>>import com.tomsnyder.fasttmath2.tests.AllTests; //my
>>implementation of
>>
>>TestSuite
>>
>>import com.blitzagency.xray.util.XrayLoader;
>>
>>import com.dynamicflash.utils.Delegate;
>>
>>import org.as2lib.test.unit.XmlSocketResultPrinter;
>>
>>import asunit.runner.BaseTestRunner;
>>
>>
>>
>>class com.tomsnyder.fasttmath2.tests.AntTestRunner extends
>>
>>BaseTestRunner
>>
>>{
>>
>>
>>
>>      public function AntTestRunner()
>>
>>      {
>>
>>            super(XmlSocketResultPrinter);
>>
>>            start(AllTests);
>>
>>     }
>>
>>
>>
>>    public static function main():Void
>>
>>    {
>>
>>            var runner:AntTestRunner = new AntTestRunner();
>>
>>    }
>>
>>
>>
>>}
>>
>>
>>
>>Hopefully that help a little more.
>>
>>
>>
>>good luck.
>>
>>
>>
>>-Chris
>>
>>
>>
>>_______________________________________________
>>
>>osflash mailing list
>>
>>[email protected]
>>
>>http://osflash.org/mailman/listinfo/osflash_osflash.org
>>
>>
>>
>>_______________________________________________
>>
>>osflash mailing list
>>
>>[email protected]
>>
>>http://osflash.org/mailman/listinfo/osflash_osflash.org
>>
>>_______________________________________________
>>osflash mailing list
>>[email protected]
>>http://osflash.org/mailman/listinfo/osflash_osflash.org
>>
>>
>>
>>    
>>
>
>
>  
>

-- 
Simon Wacker
www.simonwacker.com
www.as2lib.org
www.hq-heilbronn.de
www.flik-flak.de


_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org

Reply via email to