|
From: Alias <ali...@gm...> - 2005-11-13 01:55:06
|
Hi Luke, Just tried the createclass XUL application - that's pretty neat. It actually seems to work much better than the JSFL version. Good stuff :) I'll let you know if I manage to break it. Alias On 11/13/05, Matt Freer <mat...@gm...> wrote: > Hey Luke, > > Thanks for your reply. > > >> events in AS 3.0 fire synchronously, so I usually test them by > triggering the event and > >> then checking the state of the object in a regular TestCase. > > The approach I have been using sounds the same: > 1) In my TestCase I write a test designed to test the state of the > object after an Event has fired. > 2) In my Testcase I override the run method and trigger the event > (subscribing to it) > 3) In the event handler I call super.run(); > > The problem I find with this approach is that if the event doesn't > fire (for whatever reason) then super.run() is never called and hence > no tests run/no tests fail! > In larger projects when you have perhaps 100s of tests it becomes > harder to track the exact number of tests expected to run. Hence you > can be in a situation when all your tests appear to be passing, but in > reality all your tests aren't running. > > I have experimented with including timeout checks (to test whether the > event fired) however I find this to be pretty messy and generally find > that the TestCases don't scale particularly well in such when this is > implemented. > > Do you also find this a problem? > > > >> Mock Objects are also useful when testing abstract classes > > I had actually been using Concrete implementations of Abstract Classes > designed specifically for testing purposes, so this seems to fit with > the description of Mock Objects. > > Thanks for all the info > > Cheers > Matt > > > > On 11/13/05, Luke Bayes <lb...@gm...> wrote: > > Hey Matt, > > > > Thanks for the kind words! > > > > I'm really glad to hear that someone got the XUL UI and AsUnit 3.x up = and > > running! > > > > > > > I wondering if the new Event Model in AS3, with its bubble nature > > > will make it easier to test event based code? > > > > That's actually a very good idea, I haven't really messed with the bub= ble > > feature much yet... If you get something going like that, I would love = to > > see it. > > > > As far as using AsynchronousTestCase to test event based code, I'm not= sure > > that's really the best way because events in AS 3.0 fire synchronously,= so I > > usually test them by triggering the event and then checking the state o= f the > > object in a regular TestCase. > > > > We created the AsynchronousTestCase and Example because there are occa= sions > > where we wanted to test functionality that isn't compiled into the swf = file. > > EG: Loaders and Sockets. > > > > This actually leads nicely into your next question: > > > > > > > Also can you please explain the nature of Mock Object Test Cases - an= d > > > when we might choose to use one? > > > > Generally, when you want to test an object that consumes asynchronous > > functionaliy (like the client of a Socket connection), you should typic= ally > > build a Mock Object of the Socket and use that instead of the Socket it= self. > > This is different from testing the Socket. As mentioned before, an > > AsynchronousTestCase would be used to validate the Socket, but then a > > SocketMock would be used to test it's clients. > > > > http://c2.com/cgi/wiki?MockObject > > > > Mock Objects are also useful when testing abstract classes. Of course = AS > > 3.0 doesn't natively support the abstract keyword, but we have been > > implementing abstract classes by throwing an error in the constructor, = then > > using a Mock object to validate it's functionality. > > > > Thanks, > > > > Luke Bayes > > www.asunit.org > > > > > > > > > ------------------------------------------------------- > SF.Net email is sponsored by: > Tame your development challenges with Apache's Geronimo App Server. Downl= oad > it for free - -and be entered to win a 42" plasma tv or your very own > Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php > _______________________________________________ > Asunit-users mailing list > Asu...@li... > https://lists.sourceforge.net/lists/listinfo/asunit-users > |