Tuesday, April 05, 2011

Darren on Flex: FlexUnit4 Testing with Parsley

I've explored in the past the features of FlexUnit4, specifically its asynchronous and UI capabilities, to test the behaviour of the mixins over at my Flexins Project. Recently, however, I've been using Cairngorm and Parsley on an assignment and I've channelled my efforts into testing UI-logic. I've deferred testing views for the time being, focusing on Parsley Command objects and Cairngorm-style presentation-models (PMs) - typically objects containing logic that is triggered by the Parsley Messaging framework.

I am using FlexUnit, but I recognise some might classify this testing as something other than unit-testing; calling it integration-testing seems a bit grand, seeing as for a Flex application, being traditionally client-server, I'm not integrating anything. I'd rather call it component-testing, looking at it from the point of view that I target the collaboration of a small subset of classes that support one functional area of the application.

Still, by saying that, what I really want to acknowledge is that there maybe better tools for this kind of testing. For example I am a fan of Behaviour Driven Development and have also explored using Cucumber, FunFX and Melomel.

This blog series is really just an account of what I have achieved in proving the concept of Parsley supporting FlexUnit testing.... of Cairngorm stuff.

Where I am a fan of DSLs, I will also show you how an embedded DSL can be used to introduce a bit of flow to your tests and abstract away details that gradually starts to make my head spin.

I re-iterate, it's all just a display of what can be done - it's by no means polished and I'm not even claiming that it's a good approach - it's simply a workable approach to shake-down your message wiring and interactions between Parsley-managed objects.

  1. Unit Testing Command Objects
  2. Asynchronous Testing with Parsley and Fluint Sequences
  3. Hiding Fluint Sequences with a Flow-based DSL
  4. Improved Parsley Support with FlexUnit's [RunWith(...)][Rule]
  5. Testing with a Parsley-Aware DSL
  6. Testing with Mock Injections
I hope you find it useful.

Update:

FlexUnit 4.1 has been released, providing new features including the handy [Rule] hook-mechanism

No comments: