Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: PureMVC FlexUnit Testing  (Read 14190 times)
Larry Marburger
Newbie
*
Posts: 2


View Profile WWW Email
« on: June 11, 2008, 05:28:44 »

I've been getting into some Flex 3 lately and have been loving both PureMVC Standard and MultiCore.  Without PureMVC, my Flex and Flash code would be (and is) a total mess.  So amazing job, PureMVC team.  I'd be lost without you.

Recently I picked up a copy of the Flex 3 Cookbook and was drawn into the chapter on FlexUnit.  I played with some of the samples and immediately tried to apply it to the PureMVC Flex project I was working on.  All was well until I tried to write some simple unit tests for various asynchronous web service methods in a Proxy.  The FlexUnit way of dealing with asynchronous interactions is to use their addAsync() factory method when attaching to an EventDispatcher with addEventListener().  Since PureMVC doesn't throw events (at least not to my knowledge -- it may behind the scenes), I had to hack something together.

And so the PureMVC FlexUnit Testing project was born.

I made a detailed write-up for those interested laying out how it works and my thought process.  I did some research before going down this road but couldn't find anyone with a similar solution.  Maybe I'm blind or maybe I just wasn't asking the right questions.

I'd love to get some feedback from the PureMVC community.  Is this an acceptable way to go about unit testing asynchronous Notifications or is there something completely obvious I'm missing?
Logged
Daniel
Newbie
*
Posts: 2


View Profile Email
« Reply #1 on: July 30, 2008, 06:00:02 »

Quick question: How can I get this to run the tests one after the other?  I've got a proxy that is a piece of media and obviously I can't execute multiple tests on it at the same time (i.e seek, next frame, etc.).
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #2 on: July 30, 2008, 07:08:50 »

If you're using MultiCore, you can get a new Facade instance for each test, so that will keep actions from the previous test from affecting the next one.

-=Cliff>
Logged
Daniel
Newbie
*
Posts: 2


View Profile Email
« Reply #3 on: July 30, 2008, 08:56:47 »

Nope, not using Multicore.  Good suggestion though.
Logged
sjlib
Newbie
*
Posts: 1


View Profile Email
« Reply #4 on: January 13, 2009, 01:25:37 »

When looking at this, it makes sense and is a nice way of 'short circuiting'? the framework for unit testing. The only thing I got hung up on is
:
// Manually register an observer on this proxy for the specified notification.
view.registerObserver(notificationName, new Observer(handler, this)); }
Larry admits this is not very clean. I'm not sure this can be done any other way. It seems registerObserver is only defined on IView. Is there in fact some other mechanism by which to register an Observer ? I'm guessing no.

Thanks.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #5 on: January 14, 2009, 06:36:46 »

No, but the code seems fine.

-=Cliff>
Logged
Pages: [1]
Print