FlexUnit 4 – Starting out

For any of you familiar with FlexUnit 1, Fluint, or FlexUnit 4, move along. This is probably going to be so simple you will scoff at it. For those of you who haven’t started out with any unit testing, especially the new FlexUnit 4, then read on.

First:

FlexUnit 4 has NOTHING to do with Flash Builder 4 in terms of version number. It actually relates to JUnit 4 (which specific version, I don’t know, someone?). So for those of you wondering, yes, it can test Flex 3 SDK , not just Flex 4 SDK projects.

Next: Getting started

Whether you have an already created project, or are starting a brand new one, there is a simple set of steps that you can perform in Flex Builder 4 to set up your project for unit testing.

I am writing this, because I thought it should be easy, and it is, I just went about it the wrong way and I want you out there to not have to make the same mistake.

Originally, I was right clicking on the Package Explorer and trying to use Execute FlexUnit Tests menu item. While this will eventually work, it won’t yet. Why? You haven’t set up your project to know that it has FlexUnit tests!

Steps: (This is the way I know how to do it, if you know another way, let me know!)

  1. Select Run > Run > FlexUnit Tests
    1. This brings up a progress dialog that sets up all of the libraries into your project.
    2. Then the Run FlexUnit Tests dialog comes up.
    3. If you haven’t written any tests yet, then you can only Cancel from this.
  2. Write some tests!
    1. Create a new package that will contain all of your tests. This way you can keep track of them more easily and separate them out of your production code.
    2. A simple testing class will look like this:
    3. package TestingPackage
      {
      	import flexunit.framework.Assert;
      
      	public class TestSampleLayout
      	{
      		[Test]
      		public function testAssertFalse():void
      		{
      			Assert.assertFalse( false );
      		}
      
      		[Test]
      		public function testSampleLayoutFunctionReturn():void
      		{
      			var initialString : String = "Hello World.";
      			var finalString : String;
      			finalString = new SampleLayout().sampleFunctionReturnTest( initialString );
      			Assert.assertEquals( initialString, finalString );
      		}
      
      		public function TestSampleLayout()
      		{
      		}
      	}
      }
    4. This class does two tests.
      1. It asserts that False really is false. You normally wouldn’t do this, but it shows you something of what you can do.
      2. It tests the method “sampleFunctionReturnTest” of the class SampleLayout. The method merely spits back whatever string it was entered.
    5. So when it gets run through AssertEquals, and they are equal, then the test passes. If they are not, then it would fail.
  3. Note that before each test method is [Test], this is what FlexUnit 4 uses to determine if a method is a test or not. So you need that before every test you want run.

I am still working out all of the different types of testing that are available, but this should hopefully get you started until I post more, or more documentation becomes available.

Flex and ColdFusion 101 – Jeff Tapper – Flex Camp Chicago 2009

In the spirit of getting these out to you faster, but still much slower than I want to, here is the fifth session of Flex Camp Chicago 2009. It is Flex and Cold Fusion 101 with Jeff Tapper.

Integrating Flex with Java and PHP – Shashank Tiwari – Flex Camp Chicago 2009

This is the fourth session of Flex Camp Chicago 2009 with Shashank Tiwari on integrating Flex with Java and PHP.

As with the other sessions, this one was well presented and informative. I learned from it and I hope you will as well.

Enjoy!

My summer project – augmented reality and Flash

I was inspired recently by a man who doesn’t even know I exist (probably). That man is Saqoosha, and he lives in Japan. Some of what he does is develop the FLARToolkit.

If you haven’t seen or heard about augmented reality or the FLARToolkit, I suggest you head over to his site and take a look, or Google about it. Go ahead, I’ll wait.

So about three weeks ago I started looking into this technology and it just grabbed me. It grabbed me so hard and was shoving thoughts into my brain that I had to do something about it, thus, the summer project.

I roped another developer, Joe Adkins, into working with me, and together we are digging into the toolkit, looking at other libraries that people are creating, and in general right now getting our hands dirty with code. Right now I have code under my fingernails, code in my hair, and I dream about the toolkit at night.

You might be wondering what it is that I am actually doing with my summer project. Well, I am not going to tell you, yet. It’s still too early. Though as the name implies, I expect to have the first version done by the end of summer.

Stay tuned though, since I intend on posting some work in project shots, and maybe even a few working demos.