|
From: Luke B. <lb...@gm...> - 2005-11-12 20:49:22
|
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 bubble 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 of th= e object in a regular TestCase. We created the AsynchronousTestCase and Example because there are occasions 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 - and > 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 typically build a Mock Object of the Socket and use that instead of the Socket itself= . 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.0doesn'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 <http://www.asunit.org> |