Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
FlexUnit is a unit-testing framework for Flex and ActionScript 3 applications and libraries. It mimics the functionality of JUnit, which is a Java unit-testing framework, and it comes with a graphical test runner. Now Flash Builder 4.6 includes complete support for FlexUnit, so it's actually integrated directly into our development environment so we can run our tests directly from Flash Builder. If you browse out to flexunit.org, you can get more information on the framework. So for example, I can see all of the features, I can contribute if I like, I can access all of the docs, and you will see the docs are very neatly organized, and you could see everything that's going on.
I can also access a wiki, and of course I can download everything as well. So I can download all of the different tests that I want to use and be able to access that all from flexunit.org. What I've done is I have actually created a project for you inside of Flash Builder that contains all of the FlexUnit tests, so we can actually see how it's integrated directly inside a Flash Builder. So open up Flash Builder, click File, choose Import Flash Builder Project, and go and import your FlexUnit tests right here. Go ahead and click Finish, and you'll see we have my FlexUnitTurnkey.sdk here. And here's my project and I can indicate the source and I can see all of my different FlexUnit, so here's my actual application.
You can see that I've included the unit tests here. So the FlexUnitTests, I have included a math package, a suite package, and that sort of thing. So, it'll run this utilizing the AIR Debug Launcher and I can set up of course different device configurations. Now FlexUnit does fully support mobile as well, and you can actually test it right on the device, which can be very useful for debugging, and all you have to do is connect it to your USB port, or you can connect it over the network via WiFi. And you can utilize a socket connection and the computer's IP address to communicate between Flash Builder and the FlexUnit application running on the device.
Now all of this setup is actually detailed in the original Flex course, but again, you can do this debugging over WiFi. Before we do any of the testing, we actually need to generate a SWF file that will be located in the bin-debug folder here. So what I am going to do is I'm just going to run the tests and you are going to see the first time you do it, it's not going to run. So if I click on Run and I choose Run As, and then I choose FlexUnit Tests--it might take just a second here-- you're going to see the first time since we've imported this it's not going to run.
Okay, it's going to update the build path. Let's just choose a couple of tests here. You also see there are some errors, but that's okay. We are testing our project here. Probably expect some errors. So again, we are going to get an error because that SWF file is not actually located in the bin-debug. So I am going to go ahead and proceed, and you'll see it says file not found, right. It can't actually find the SWF file. So I am going to need to run it one more time to actually get these results. So here I'll just again run the tests again, so I will say Run As > FlexUnitTests, go ahead and choose some of the tests here, don't need to choose them all, and you should see this time it will run, and we should see that our Flash Builder tests are being run.
So you can see the execution is in process, and we can get some basic information directly from this file. So again, I can rerun tests, I can cancel running tests, and I can see all of that. You will see that in this case, if I look at the different tests, I could see 72 different tests have been run. It passed 62, it failed 1, and there's been 9 errors, and nothing has been ignored. Okay great! So now I can close this window once all those tests have actually run, and you'll see I can see the results of the tests directly inside of Flash Builder under the FlexUunit Results.
So this panel lists all the tests within the test run, indicating whether the test has passed or failed. So I can actually double-click right on the test and it will jump me to that ActionScript, so I can see what's going on. And again, if there was a failure, it would jump me right there and I can also filter the results. I can see all of that directly from my panel here in terms of a FlexUnit result testing. So now this is integrated directly into Flash Builder 4.6 and makes testing our applications much, much easier.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 101110 Viewers
61 Video lessons · 87880 Viewers
71 Video lessons · 71753 Viewers
56 Video lessons · 103621 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.