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: unit testing, how to start  (Read 7174 times)
titouille
Newbie
*
Posts: 3


View Profile Email
« on: May 23, 2008, 06:33:35 »

Hello forum !!

I use PureMVC since last year, and be very happy with this architecture. Now in my current project, my customer want to add unit testing into the application. I have read about unit tests (I'm a newbie in unit tests), made some tests with a simple project and flexunit. Now, I would like to integrate unit testing into my pureMVC application, and really don't see how to start with it...

First, which unit testing framework to use... Flexunit, ASunit, Funit ??

Second, how to integrate unit tests into a big application ?? To test only piece of code in a function, it's not really a problem... but to test cyclic processes like :

1. component dispatch an event
2. mediator handle event and send notification to execute command
3. command execute it process and send an alert notification
4. mediator(s) handle the alert notification to know that the command was correctly executed

Must I integrate the testRunner into the application itself ? because if I want to use the whole process, Application, mediators, views, models, commands must be instanciate... I can't create a new project and instanciate only the mediator or the command I would like to test because there is a lot of dependencies on facade, notifier, etc...

Is there some samples about ? I searched for several hours and don't find any, even minimal, tutorial, sample or documentation :-(

Any code snippets or way to follow would be appreciated. Thanks a lot in advance (and sorry for my english).

Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #1 on: May 23, 2008, 07:27:05 »

Wow, too funny. I came here today looking for the exact same question. I hope someone can give us a little guidance. As you say, testing individual functionality of components, proxies and commands is not difficult... but how to test the orchestration of the framework flow is another beast I can't even begin to understand where to start. I suppose for now I'll stick to testing the above mentioned areas, but hope someone can shed some light on testing the stability of things like start-up and shutdown of the app, event flow and user input.

My current project is quickly growing in size, up to about 300 files now and roughly 33,000 lines of code, and testing it's integrity is getting to be more and more important.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #2 on: May 23, 2008, 08:11:24 »

Hi guys,

This week I've got unit testing on the brain. I just finished porting the PureMVC framework unit tests to MultiCore, and have been unit testing a new utility called Pipes for inter-modular communications into stability one test at a time.

If you search these forums for 'unit test', you'll find most of the advice centers around testing pieces in isolation. An undesirable effect of the Singletons can be the inability to start each test with a fresh set of core actors.

An interesting 'feature' of MultiCore in regards to testing is that you can have a fresh core for each test. Just use a unique Multiton key each time. So even if you're not using modules or loaded swfs with separate 'cores' running in them, the testing side of things may make MultiCore a little more attractive.

But still, testing cascading responses is within your app is not really practical with traditional testing tools.
 
We need a testing tool that works within the PureMVC app somehow. Like what Cactus does for testing in-container Java EE apps.

Perhaps a testing version of the framework where every actor pipes info about its actions to message queue which you then make assertions about the content of...

-=Cliff>
Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #3 on: May 23, 2008, 09:32:41 »

We need a testing tool that works within the PureMVC app somehow. Like what Cactus does for testing in-container Java EE apps.

Perhaps a testing version of the framework where every actor pipes info about its actions to message queue which you then make assertions about the content of...

-=Cliff>

That sounds like a great idea. I'm interested in seeing the flow of data through the different stages of events to see potential problems where data is being changed incorrectly by something along the way (data leaves a proxy -> altered by a command -> altered again by mediator maybe -> rendered to visual component or lost along the way due to incorrect note name or type for example). My ideal testing would let me run a normal suite of unit test on things like components and proxies, and then a completely separate test afterwards that list the state of information as my app journey's through start-up and operation. Some sort of a tracing of information as I actually click test the app would be ideal.
Logged
Pages: [1]
Print