|
From: Darren C. <da...@dc...> - 2006-02-23 02:56:58
|
Hi, I want to write some unit tests for an AS2 library (open source) that I'm working on. I keep looking at asunit but just cannot grasp how to use it. I think my question boils down to: is there a commandline test runner? What I want to do is be able to type "make test" (I may use ant, as that seems more popular in the flash community, but same principle) and be told either OK or be told which tests failed. I guess "make test" would run something like: asunit path/to/directory_full_of_*Test.as Is this possible with asunit currently? Thanks, Darren P.S. Has anyone done/seen a comparison of asunit with as2lib's unit testing framework? I can only find API docs for that so am even more in the dark about how I'd use it. |
|
From: Luke B. <lb...@gm...> - 2006-02-23 08:22:52
|
Hey Darren, This is a great question, and you're not the first one to ask! The short answer is, unfortunately, no. The long answer is, sort of... with a small bit of work. AsUnit 2.x currently uses a flash LocalConnection object to transmit test status to a visual user interface. If you made some *very* minor modifications to the source code, you could send that info to trace instead= . If this build were then run inside of the "debug" player, using a "debug" swf file, you could configure your "mm.cfg" document so that all trace output is sent to a log file. You could then monitor this log file for failures so that you get the expected output. Ultimately, in order to get something like "asunit YourClassTest.as", you would have to write some kind of shell script or application that essentially: a) ran mtasc YourClassTest.as and created YourClassTest.swf b) opened the SAFlashPlayer.exe with YourClassTest.swf c) read the log file (which you have to configure mm.cfg for) and send it t= o std out. This sounds like a lot, but it actually shouldn't be too much work... If you do wish to make changes to the AsUnit sources, please let us know before you begin so that we can make sure you have the latest source code. As for a comparison between AsUnit and the aslib stuff, I'm sorry to say that I really can't help you there. I haven't taken a look at that stuff fo= r a long time. Thanks, Luke Bayes www.asunit.org On 2/22/06, Darren Cook <da...@dc...> wrote: > > Hi, > I want to write some unit tests for an AS2 library (open source) that > I'm working on. I keep looking at asunit but just cannot grasp how to > use it. I think my question boils down to: is there a commandline test > runner? > > What I want to do is be able to type "make test" (I may use ant, as that > seems more popular in the flash community, but same principle) and be > told either OK or be told which tests failed. I guess "make test" would > run something like: > asunit path/to/directory_full_of_*Test.as > > Is this possible with asunit currently? > > Thanks, > > Darren > > P.S. Has anyone done/seen a comparison of asunit with as2lib's unit > testing framework? I can only find API docs for that so am even more in > the dark about how I'd use it. > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting > language > that extends applications into web and mobile media. Attend the live > webcast > and join the prime developer group breaking into this new coding > territory! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat= =3D121642 > _______________________________________________ > Asunit-users mailing list > Asu...@li... > https://lists.sourceforge.net/lists/listinfo/asunit-users > |
|
From: Darren C. <da...@dc...> - 2006-03-03 02:00:12
|
> AsUnit 2.x currently uses a flash LocalConnection object to transmit test > status to a visual user interface. If you made some *very* minor > modifications to the source code, you could send that info to trace instead. Hi Luke, Can you give me a clue (e.g. file/class/function/line number/whatever) where these changes would go. I had a poke around the source code files but couldn't quickly find one simple place where all success/failure messages go through. (I plan to try using an XML socket instead of trace, but I assume code change would be the same.) Thanks, Darren > If this build were then run inside of the "debug" player, using a "debug" > swf file, you could configure your "mm.cfg" document so that all trace > output is sent to a log file. You could then monitor this log file for > failures so that you get the expected output. > > Ultimately, in order to get something like "asunit YourClassTest.as", you > would have to write some kind of shell script or application that > essentially: > > a) ran mtasc YourClassTest.as and created YourClassTest.swf > b) opened the SAFlashPlayer.exe with YourClassTest.swf > c) read the log file (which you have to configure mm.cfg for) and send it to > std out. > > This sounds like a lot, but it actually shouldn't be too much work... > > If you do wish to make changes to the AsUnit sources, please let us know > before you begin so that we can make sure you have the latest source code. > > As for a comparison between AsUnit and the aslib stuff, I'm sorry to say > that I really can't help you there. I haven't taken a look at that stuff for > a long time. > > > Thanks, > > > Luke Bayes > www.asunit.org > > > > On 2/22/06, Darren Cook <da...@dc...> wrote: > >>Hi, >>I want to write some unit tests for an AS2 library (open source) that >>I'm working on. I keep looking at asunit but just cannot grasp how to >>use it. I think my question boils down to: is there a commandline test >>runner? >> >>What I want to do is be able to type "make test" (I may use ant, as that >>seems more popular in the flash community, but same principle) and be >>told either OK or be told which tests failed. I guess "make test" would >>run something like: >> asunit path/to/directory_full_of_*Test.as >> >>Is this possible with asunit currently? >> >>Thanks, >> >>Darren >> >>P.S. Has anyone done/seen a comparison of asunit with as2lib's unit >>testing framework? I can only find API docs for that so am even more in >>the dark about how I'd use it. >> >> >>------------------------------------------------------- >>This SF.Net email is sponsored by xPML, a groundbreaking scripting >>language >>that extends applications into web and mobile media. Attend the live >>webcast >>and join the prime developer group breaking into this new coding >>territory! >>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 >>_______________________________________________ >>Asunit-users mailing list >>Asu...@li... >>https://lists.sourceforge.net/lists/listinfo/asunit-users >> > > |
|
From: Luke B. <lb...@gm...> - 2006-03-04 20:14:42
|
Hey Darren, Sorry for the confusion... The file in question is located in framework/as2/com/asunit/framework/TestRunner.as The TestRunner.push method is called from framework/Assert.as inside of addTestResult, which is called from the body of every Assert method (like assertTrue). The TestRunner is instantiated using a singleton factory method that is als= o inside of Assert at "getTestRunner()". I recognize the obvious flaws in thi= s design, and they will likely be changed in the not-too-distant future... Bu= t that's how it works now... Ideally, you should be able to extend a base class "TestRunner", and then users could choose where to send output... The File System, Local Connection, Trace, an XML Socket, SMS, Email, etc... My understanding is that there are at least 4 or 5 people interested in thi= s feature and at least 3 of them seem to be working on it right now. Can I get a roll call for those of you that are in fact interested in getting the AS 2.0 build to support multiple test runners? Of those of you that raised your hands how many have already implemented it= ? Or are willing to get it implemented? Thanks, Luke Bayes www.asunit.org |
|
From: Darren C. <da...@dc...> - 2006-03-06 05:17:57
|
Hi Luke, Thanks for the reply. > The file in question is located in > framework/as2/com/asunit/framework/TestRunner.as > > The TestRunner.push method is called from framework/Assert.as inside of > addTestResult, which is called from the body of every Assert method (like > assertTrue). OK, I see. Yes, it looks like the change should be quite straightforward. For proof-of-concept I'll try just replacing that whole file. (See P.S. for comments/questions on existing code.) > Ideally, you should be able to extend a base class "TestRunner", and then > users could choose where to send output... The File System, Local > Connection, Trace, an XML Socket, SMS, Email, etc... Yes. > My understanding is that there are at least 4 or 5 people interested in this > feature and at least 3 of them seem to be working on it right now. > > Can I get a roll call for those of you that are in fact interested in > getting the AS 2.0 build to support multiple test runners? > > Of those of you that raised your hands how many have already implemented it? > Or are willing to get it implemented? I'm willing to work on an XML sockets version, with a PHP back-end. Darren P.S. http://svn.sourceforge.net/viewcvs.cgi/asunit/trunk/framework/as2/com/asunit/framework/TestRunner.as?view=markup&rev=2 I think the renderTests(arr:Array) function should be changed to renderTests(Void), and then change: lc["addTests"](arr); tests = new Array(); to read: lc["addTests"](tests); tests = new Array(); The reason is simply that this.tests gets reset so passing in anything other than this.tests is dangerous. While there I think renderTests() and getLocalConn() can be changed from public to private: no other classes seem to call them. addSuccess() and addFailure() don't seem to be called from anywhere at all. What are they for, and do they need to be part of the public interface? |
|
From: Luke B. <lb...@gm...> - 2006-03-06 05:46:04
|
Hey Darren, Thanks for checking into this. Answers inline below: http://svn.sourceforge.net/viewcvs.cgi/asunit/trunk/framework/as2/com/asuni= t/framework/TestRunner.as?view=3Dmarkup&rev=3D2 > > I think the renderTests(arr:Array) function should be changed to > renderTests(Void), and then change: > lc["addTests"](arr); > tests =3D new Array(); > to read: > lc["addTests"](tests); > tests =3D new Array(); > > The reason is simply that this.tests gets reset so passing in anything > other than this.tests is dangerous. Good point. Thanks! While there I think renderTests() and getLocalConn() can be changed from > public to private: no other classes seem to call them. This seems correct to me too. addSuccess() and addFailure() don't seem to be called from anywhere at > all. What are they for, and do they need to be part of the public > interface? I believe these methods can actually be removed. They represented an early design that didn't make it into the final build. Overall - nice finds! I'll update the source in svn right now with these changes. Luke Bayes www.asunit.org |
|
From: Darren C. <da...@dc...> - 2006-03-22 05:17:31
|
>>The file in question is located in
>>framework/as2/com/asunit/framework/TestRunner.as
>> ...
> For proof-of-concept I'll try just replacing that whole file.
> ...
> I'm willing to work on an XML sockets version, with a PHP back-end.
I have a working proof-of-concept now, so unless someone is already
working on this I'll go ahead and do it properly. This will just be in
the as2 branch (I need Flash 6 support so haven't looked at as25/as3).
My proposed changes:
1. Split TestRunner into TestRunner and TestRunnerLocalConnection.
(I.e. TestRunner will become an abstract base class)
2. Add TestRunnerXMLSocket as an alternative
3. In Assert.as's getTestRunner() decide what type of object to return.
We need a way to tell Assert which TestRunner to use.
TestRunnerLocalConnection needs no parameters, but XMLSocket needs an IP
and port. By idea is to define these vars in Assert:
public static TestRunnerType:String="LocalConnection";
public static TestRunnerParameters:String=null;
So by default it will work the way it does currently, and to use an
XMLSocket I'd write this code:
Assert.TestRunnerType="XMLSocket";
Assert.TestRunnerParameters="127.0.0.1:9123";
Any opinions?
Darren
|
|
From: Darren C. <da...@dc...> - 2006-03-29 08:53:07
|
Hi, I've implemented the below proposal. See the attached zip file [I just discovered I cannot post zip files - if you want me to send it to you directly let me know]. Put those 4 files in your as2/com/asunit/framework directory (2 files get replaced, 2 new files). (My changes tested with latest SVN, but I believe the last release is currently identical.) The defaults use LocalConnection so should work just as before. To use the XMLServer, you need to do two things: 1. Add these two lines to your main(): Assert.TestRunnerType="XMLSocket"; Assert.TestRunnerParameters="127.0.0.1:9123"; 2. Make a socket server that listens on 127.0.0.1, port 9123. I've a half-finished PHP script that makes the actionscript, runs mtasc, runs the tests, listens on the socket, and reports the results. I might not have that ready until next week (feel free to push me). BTW, Assert.as in the zip file also contains the assertEquals improvements mentioned in my next email. Darren >>>The file in question is located in >>>framework/as2/com/asunit/framework/TestRunner.as >>>... >> >>For proof-of-concept I'll try just replacing that whole file. >>... >>I'm willing to work on an XML sockets version, with a PHP back-end. > > > I have a working proof-of-concept now, so unless someone is already > working on this I'll go ahead and do it properly. This will just be in > the as2 branch (I need Flash 6 support so haven't looked at as25/as3). > > My proposed changes: > > 1. Split TestRunner into TestRunner and TestRunnerLocalConnection. > (I.e. TestRunner will become an abstract base class) > > 2. Add TestRunnerXMLSocket as an alternative > > 3. In Assert.as's getTestRunner() decide what type of object to return. > > We need a way to tell Assert which TestRunner to use. > TestRunnerLocalConnection needs no parameters, but XMLSocket needs an IP > and port. By idea is to define these vars in Assert: > > public static TestRunnerType:String="LocalConnection"; > public static TestRunnerParameters:String=null; > > So by default it will work the way it does currently, and to use an > XMLSocket I'd write this code: > Assert.TestRunnerType="XMLSocket"; > Assert.TestRunnerParameters="127.0.0.1:9123"; > > Any opinions? > > Darren > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting language > that extends applications into web and mobile media. Attend the live webcast > and join the prime developer group breaking into this new coding territory! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 > _______________________________________________ > Asunit-users mailing list > Asu...@li... > https://lists.sourceforge.net/lists/listinfo/asunit-users > > |
|
From: Darren C. <da...@dc...> - 2006-04-02 02:18:26
|
> I've a half-finished PHP script that makes the actionscript, runs mtasc, > runs the tests, listens on the socket, and reports the results. I might > not have that ready until next week (feel free to push me). I've put this up here: http://dcook.org/software/asunit_socket_server.zip (21K) It contains both the asunit actionscript patches, and the PHP server. It is reasonably documented: see the readme.txt, and there is also an example file. I've pasted in the motivation section from the readme file in case you're wondering "why?". The configuration is ready to go for linux using gflashplayer (i.e. Flash 6), but it should be easy to configure to work on windows and mac. Darren ------------------------------------- MOTIVATION A way to run actionscript unit tests fully automatically, using only the commandline, was required, but flash cannot write to the file system or stdin/stdout. Therefore we use the XML sockets to pass the test results out of flash to a back-end server. Another key requirement was it should work on all of linux, windows and mac. Running tests automatically allows us to release actionscript libraries with makefiles that have a "make test" option. Other possibilities include running all project unit tests in an overnight regression test run. Or forcing tests to be run on a server before allowing a source control check-in. |
|
From: Darren C. <da...@dc...> - 2006-02-23 13:23:28
|
> AsUnit 2.x currently uses a flash LocalConnection object to transmit test > status to a visual user interface. If you made some *very* minor > modifications to the source code, you could send that info to trace instead. Thanks for the reply. It sounds like it could equally well go down an XML socket? I'm familiar with that, and the necessary PHP server code to catch the messages. Can you let me know which source file(s) would need to be modified, and I'll take a look and if not too major I'll try it out. (I have downloaded 2.7alpha but could do a cvs checkout if the relevant code has changed a lot.) Darren |
|
From: Peter H. <pet...@gm...> - 2006-02-23 13:38:13
|
Additionally, if you want to do this with Flex, I can give you some tips. Peter On 2/23/06, Darren Cook <da...@dc...> wrote: > > > AsUnit 2.x currently uses a flash LocalConnection object to transmit > test > > status to a visual user interface. If you made some *very* minor > > modifications to the source code, you could send that info to trace > instead. > > Thanks for the reply. It sounds like it could equally well go down an > XML socket? I'm familiar with that, and the necessary PHP server code to > catch the messages. > > Can you let me know which source file(s) would need to be modified, and > I'll take a look and if not too major I'll try it out. (I have > downloaded 2.7alpha but could do a cvs checkout if the relevant code has > changed a lot.) > > Darren > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting > language > that extends applications into web and mobile media. Attend the live > webcast > and join the prime developer group breaking into this new coding > territory! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat= =3D121642 > _______________________________________________ > Asunit-users mailing list > Asu...@li... > https://lists.sourceforge.net/lists/listinfo/asunit-users > |