Unit-testing PureMVC

My current project is a timeline-based Actionscript 1.0 app, which is about as unmaintainable as it gets. When I started the backlog of change requests and updates was at least three months long, so making the site more easily updatable was a priority, in among doing the updates.

It’s a sprawling mass of code, with no division of responsibility anywhere, so bits of code spread out over the whole system are wired into each other, and it all feels like I’m left with wire-cutters and a bomb.

Enter PureMVC.

I’ve been looking for a panacea-like framework for some time, and this may just be it. The documentation is excellent. Can I say that again, and emphasise how important it is? The documentation is excellent.

And, more recently, it’s been ported backwards to Actionscript 2.0, which is my current domain, so I can use it to pull this labyrinthine project into shape.

I noted, however, that the unit tests hadn’t been ported back, so I converted them on a commute. Why? Apart from anything else, the tests demonstrate how the original architect and developer, Cliff Hall, wanted his framework to be used.

So, converting a legacy project without breaking any of it: unit tests are pretty much my only safeguard. As I go through the old code and find an exception to a rule (and there are lots), I can write a test to verify that behaviour, and then get on with re-writing the code. As long as the tests continue to pass, I’m safe (until next time!).

Two follow-ups required: how to write unit tests for Actionscript 2.0 (hint: take a look at asunit); how to write tests around the peculiarities of puremvc? More to follow …

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

1 Comment

  1. Luke Bayes — April 17, 2008 @ 5:55 pm

    This is a great article and I’m glad to see both PureMVC and TDD getting more attention these days.

    Please keep sharing your experiences with unit testing ActionScript applications, and if you have any questions or just want to talk about what you find, don’t hesitate to check in!

    By the way – Sprouts – my latest open source project (http://www.projectsprouts.org) may be helpful during your migration as it will allow you to easily move toward the mtasc compiler and migrate your complex FLA to become a much simpler library SWF

RSS feed for comments on this post. TrackBack URI

Leave a comment