Virtual Thoughts from eRoom-D

Thoughts on web development, Flash, Flex, and game design.

FlexUnit 4 – Starting out

October28

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. ?Download download.txt
      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.

Popularity: 30%

posted under Flex, eRoom-D | No Comments »

Like my friend Chris Miller, I’m working, no really, I’m working.

July27

I’ve never been exceptionally good at keeping up with the blog here, even though this year started out fairly well. So in order to keep my momentum going, you know an object in motion tends to stay in motion, I am going to be writing these smaller updates in addition to when I get out my long tutorials and other long form posts.

I’m still working at Digital Primates and loving what I do there. I haven’t had much time while on the job to study up for the Flex Developer’s Certification, so I do that as much as I can from home. I need to take a practice test or two to see where I would score if I took the actual test, and where I need to focus my studies to make sure I pass.

Over the last several months I have worked more with the Flex Framework than I have ever before. I am so used to doing things in pure AS2 an AS3, that I had to retrain myself to look for things in the framework that were already waiting for me to just use them. Some of the people at DP also have been a great help in this. I’d thank them all here, but I’d really be thanking everyone at the company, so thanks guys.

Moving on into the late summer, I am still working on my augmented reality project. My friend and now co-worker (he’s an intern at Digital Primates), Joe, is helping me work through the FLARToolkit. Making things make sense, and finding out where we can speed things up. Optimization was the main topic last week. This week it was me solo, but I was able to get DAZ3D models into our app. Definitely need more optimizing there (15 Meg for a model! jeesh!).

Oh, and I am also now a contributor to the FLARToolkit’s repo. Haven’t submitted anything yet, but I should before the next post. So with Podiobooks.com, this is the second open source project that I am currently active in.

I may get out another post before Gen Con, so stay tuned.

Popularity: 2%

360|Flex – An amazing experience.

May22

So I got back from 360|Flex just the other day, and I am still excited about all of the people I met there, the things that I participated in, and the knowledge that I gained.

The sessions were nearly all good, I gained both knowledge and varying ways of presenting from them. I did record most of the sessions that I participated in, but since I am behind on getting Flex Camp Chicago recordings to you, and I didn’t get permission to post recordings, they won’t show up here. Don’t despair though, the Flex Show recorded all of the sessions and will be releasing them. When they do I will notify you here.

A note for all future presenters, if you use an internet connection for your presentation make sure you have a backup plan or can talk past it. I saw at least two presentations where the connection was too slow to be useful. One handled it smoothly, the other was derailed and was less engaging because of it.

I participated in the Charity Code Jam for the Leukemia & Lymphoma Society (LLS). It was an app that would track runners in a marathon via RFID and display the runners on the map. It also allowed coaches to look up and change runner information, volunteers to check in runners, and had an interactive mode for spectators to look up individual runners. It was an amazing time, and I met a lot of great developers of all skill levels. We got the app to about 70% for the Wednesday keynote speech, and since I had been up for more than 24 hours straight at that point I ended my participation there. The code is open source, and will be released for further development and use in other marathons. So when I find out where the project is going to be hosted, I will post that here too.

The people I met at the Charity Code Jam and around the convention are people that I look forward to keeping up with. They are developers of varying stripes. People that do pure Flex, some PHP, Perl, ColdFusion, you name it and I probably could tell you someone who did it. Definitely more on those folks as I gather the business cards, twitter handles, and email addresses for them.

As I keep saying, more to come in later posts. 360|Conferences is starting to host more conferences, so if you aren’t a Flex developer they probably will have a development conference for you at some point. Right now they have an iPhone developer conference, an RIA and mobile conferences are scheduled. The blog site for 360|Conferences is very basic right now, but don’t let that put you off. This conference was excellent and if I have the time I will be going to more.

Popularity: 42%

Job search, concluded. Verdict, success!

April6

As some of you know, but some others might not, I am now employed full time again. It’s with an excellent company, Digital Primates. The company has some excellent people working there, and it has several Flex luminaries at it’s head. I’ll give you a moment to go over there and look, go ahead, I don’t mind.

Before I was hired, I thought I knew a fair amount about Flex, having been working with Flash AS2 for many years, and then moving over to Flex and AS3, it seemed more or less like a change in syntax, plus some nice things with the Flex framework that were definite improvements over the Flash IDE for developers.

I was wrong.

I thought I knew, but there is so much more that I didn’t know that I am humbled by the amount that I know is still there and the huge leap in knowledge that I have gained since working there for the few short weeks that I have been training there. Yep, you heard right, training. It’s been a while since I have worked at a job that cared enough about it’s employees, and it’s reputation enough to train new employees enough so that they can do the job right the first time.

I’ve had this blog post mostly written for at least a month now. So I am posting it here so you can get an update on what I have been doing. The rest of the post I will write up later. It will be about the Flex component framework. From what I understand, as soon as Flex 4 comes out later this year, that post may become out of date. I’ll be doing it anyway so I know it better, and there are probably more than a few people who will be using Flex 3 for a while after Flex 4 comes out. It’s just the nature of business to not upgrade right away.

Popularity: 56%

« Older Entries