Posts Tagged ‘testing’

Taming and trimming FlexUnit async tests

Thursday, February 14th, 2008

I don't have time to update the HOWTOs associated with this before I end my day at the computer, but I had an ah ha! moment this evening with regard to getting FlexUnit to play nicely with RemoteObject against a PyAMF server.

Changelogs: ah ha moment, refinement and abstraction.

Files: the new test, the new class.

Some observations, where I use terminology loosely:

  • ActionScript looks superficially like Java, which is a language that I haven't used a lot, but that I've glanced at enough to notice certain patterns.

  • ActionScript is actually more like JavaScript, but has enough static typing to make it easy to follow Java idioms.

  • FlexUnit/RemoteObject samples that I've studied seem to define callback functions for asynchronous tests outside of the test case. This is unnecessary, in my opinion, and makes the test case much less readable.

    If you look at the example test above, there are five variable assignments, then a call, that comprise the entirety of the test:

    1. Line 41-42: Trigger an asynchronous operation that will produce a value object that we want to inspect.
    2. Lines 43-48: Define a function to compare the state of that object with our expectations of it.
    3. Lines 49-54: Boilerplate to connect the two together.

To me, this is a clearer way of defining tests. I hope to refine this even further by turning item 3 above into one or two lines of code.

To get to that point, my plan is to develop an API for deleting the database collection (if allowed by the server), create an empty named database, list database names, and delete a named database. That should give me enough code to figure out where the lines of fissure are to reduce that boilerplate.

Does anyone else out there know of more FlexUnit tricks? :)

Test-driven development and Python/Flex apps

Monday, February 11th, 2008

My current work for Schevo is based on building a combination of a Python server app, an ActionScript client library, and a Flex user interface.

The project mentioned above is in very early stages, but if anyone is interested, I took some notes on creating a new test-driven Python/Flex app.

I plan to expand upon it once I get a good handle on doing an automated client/server test suite. If anyone wants to help edit or expand it, please contact me at gldnspud@gmail.com so I can give you access to the Mercurial repository.

Test-driven development in Flex

Wednesday, February 6th, 2008

I'd like to do some test-driven development in Flex right away, but I'm still looking at the options available.

The two main options seem to be ASUnit and FlexUnit.

ASUnit is the older of the two, but I think from what I've read so far I'm going to look at FlexUnit first, and if it does what I'm looking for, I'll just use it.

As far as how to get started writing tests for ActionScript code, I see there is also the corelib that Adobe is opening up, and it contains FlexUnit-based unit tests.

So, what am I looking for?

I'd like to be able to work on SchevoFlex, write tests for both the Python Side and the ActionScript side, run all of the tests at once using nose, and generally keep a fluid test-driven development cycle going... especially since part of the project is making sure we have rock-solid communications between the client and server!

Lazyweb? :)