Filed Under: Flex
I’ve been playing around with the beta of FlexUnit 4 and I must say that it is exceeding my expectations. The single most painful thing to do in FlexUnit is to perform unit testing of user interactions. With the amount of code and pain involved in doing so not many people used the framework. However with FlexUnit 4 it’s so much easier, thanks to the inclusion of the Fluint framework into FlexUnit.
There is no reason why you should not upgrade today. FlexUnit 4 is backwards compatible and you can migrate each unit test whenever you would like. With the introduction of Fluint and it’s support for Sequences it is possible to unit test user interface interactions without having to write tons of code to accomplish it. You get to write less code and another very important aspect is that you can actually understand what your tests do some time later because of the simpler syntax of testing.
FlexUnit 4 is a huge step from the old versions and it is now on the same level as JUnit and other test frameworks. Especially with the easier configuration of test runners, unit testing and continuous integration will be so much easier in the future. I am also over the moon about the FlexUnit plug-in which is coming to Flash Builder.
I have a few projects with unit tests using FlexUnit 0.9 and upgrading to FlexUnit 4 is very simple. All your tests can still be reused and all that is required is that you change the way you setup the test runner.
Here is how little I had to change in one of my projects:
private function onCreationComplete():void {
testRunner.test = createSuite();
testRunner.startTest();
}
private function createSuite():TestSuite {
var testSuite:TestSuite = new TestSuite();
testSuite.addTestSuite(SomeModelClassTest);
testSuite.addTestSuite(SomeUIComponentTest);
return testSuite;
}
....
<flexUnitUIRunner:TestRunnerBase id="testRunner"/>
With FlexUnit 4 this is actually made simpler, just have a look:
private var core:FlexUnitCore;
private function onCreationComplete():void {
core = new FlexUnitCore();
core.addListener(new UIListener(testRunner));
core.run(SomeModelClassTest, SomeUIComponentTest);
}
....
<flexUnitUIRunner:TestRunnerBase id="testRunner"/>
I assume you have read the post FlexUnit 4 feature overview which gives a hint at what you can expect. Besides this one page the documentation is pretty much non-existing, but you can have a look in the source tree in the branch 4.x for samples of how to use the new features.
One would expect that it would be possible to see all the new features documented as unit tests, however it does not seem as if the FlexUnit team believe in dog food as the unit tests are far and few between.
Go download the FlexUnit 4 Beta 1 now!
Subscribe to comments feed (this is global, not just for this entry)
Being accustomed to the development tools for Java development it has been really frustrating to move into the world of Flex and Action Script with it’s immature IDE’s. However it seems as if this is finally getting attention at Adobe and the Open Source project FlexPMD is really becoming a great tool for assuring quality [...]
I have for some time been running Ubuntu on my work-at-home-computer. Having to work with Flex on Linux is a constant struggel and I can understand why most people would just give up. I can see that the number of Flex developers on Linux is quite small, however I think it’s a shame that we’re [...]
One of the most challenging tasks when being architect on a large project is to keep some kind of track on what developers are doing while you are wasting away time in planning meetings and all other kinds of useless management activities. In the Flex echo system there are very few tools which help you [...]
The only unit tests currently in the framework are the ones migrated from Fluint of FlexUnit1 to show as examples.
You are looking at an early beta, and as this is an open source project being developed purely by volunteers, you might need to give us just a bit more time before you get to see the unit tests and decide if we practice what we preach.
Incidentally, that is one of the reasons we chose to release the initial version as a turnkey and not just point people to the source; we weren’t quite ready yet.
However, feel free to join the project and help us. We always appreciate an extra set of hands.
June 22nd, 2009 at 9:25 pmI didn’t mean to offend you or in any way put down the team working on FlexUnit. You’re doing a great job and the framework is really looking great. Keep up the good work Michael!
July 17th, 2009 at 8:52 am[...] guys over at Adobe are doing some great work on a major new release of Flex Unit. A new version of Flex Builder is looming around the corner with some very promising [...]
August 6th, 2009 at 3:02 pmI’m not able to find how to structure a project the will have my Flex app, test and the test runner in the same Eclipse project. It seems, an Flex project in Eclipse, using Flex Builder can have only one main app. So, it’s either my application or the test runner. How do I solve this problem? It seems an simple issue and people must have solved it if they use flexunit for their production development, but I’m not sure how to do it.
August 10th, 2009 at 6:29 pmStanB: You can have multiple applications in your Flex Projects, but as you mention you can only have one “main application”. Main application only means the default when launching from FB, other than that there’s no difference.
August 11th, 2009 at 10:25 amYou can have the testrunner(s) and the main application in the same source tree without problems. All you need to do is to select the testrunner app and choose to run/debug it as opposed to just running the project.