Alain Hufkens {Rich Interactive Applications Developer}

30Jul/098

Testing PureMVC code with FlexUnit

The PureMVC FlexUnit Testing project is already quite old (last update was June 2008), but I just discovered it because I am currently working on a big Adobe AIR project that currently does not have a User Interface yet. We use the PureMVC framework for most of our bigger applications, and because it depends on Notifications it's not that easy to Unit Test. Proxies don't return results synchronously, but send notifications with the result in the body.

Well this small library helps connecting your PureMVC implementation code to the FlexUnit framework. The following example code shows the code for a Test Class for a DataProxy that has a method getSomeData(). As you can see, you need to write some code to access the facade, proxy, ... but it's all pretty straight forward.

package unitTests
{
  import net.hufkens.example.ApplicationFacade;
  import net.hufkens.example.config.ApplicationNotifications;
  import net.hufkens.example.model.DataProxy;

  import com.andculture.puremvcflexunittesting.*;

  import org.puremvc.as3.core.View;
  import org.puremvc.as3.interfaces.IView;

  public class DataProxyTest extends PureMVCTestCase
  {
    private var timeout:int = 0;

    public function DataProxyTest(methodName:String=null)
    {
      super(methodName);
    }

    protected function get facade():ApplicationFacade
    {
      return ApplicationFacade.getInstance();
    }

    public override function setUp():void
    {
      facade.registerProxy(new DataProxy());
    }

    protected function get proxy():DataProxy
    {
      var proxy:DataProxy =
      DataProxy(facade.retrieveProxy(DataProxy.NAME));
      return proxy;
    }

    protected function get view():IView
    {
      return View.getInstance() as IView;
    }

    public function testGetSomeData():void
    {
      registerObserver(view, proxy,
        ApplicationNotifications.GET_SOME_DATA_DONE,
        response, timeout);

      proxy.getSomeData();
    }

    private function response(e:PureMVCNotificationEvent):void
    {
      assertTrue("data is not available",
      e.notification.getBody().data.length>0);
    }
  }
}

It worked great for this project. I hope it will still be supported for Flex 4 so we can use the built-in unit testing features of Flash Builder.

Make sure you checkout the latest version from Google Code, because the swc file has an issue with multicore namespaces. The latest version in svn works fine.

Filed under: air, flex 8 Comments
15Jul/095

FlexMonkey 1.0 released (adding AIR support)

gorillalogoThis week the guys from Gorilla Logic released FlexMonkey version 1.0 beta. I have been testing the previous version on one of my Flex applications and now that they have released it as an AIR application I will definitely start using it more and more for future projects.

So, what exactly is it?

FlexMonkey is an Adobe AIR application used for testing Flex- and AIR-based applications.  Providing the functionality to record, playback and verify Flex UI interactions, FlexMonkey also generates ActionScript-based testing scripts that you can easily include within a continuous integration environment.

How does it help a developer like me build better applications? Well, you need to test your application right, and in the end you always end up doing the same actions over and over again. FlexMonkey can record those repetitive actions so you can replay this if you need to test. From those recorded actions, FlexMonkey can generate AS3 code that you can add to your project. And if you use some kind of continuous integration solution (like Cruise Control, Hudson, ...), these test cases can be plugged in and automatically executed. FlexMonkey supports Fluint and FlexUnit 4 for unit test creation and has support for Ant and Hudson. The source code is available on Google Code.

You can read more about testing your Flex application in this article on Adobe Developer Connection or check out this introduction video. It should give you an impression of what the application can do.

Congratz guys and keep up the good work!

Filed under: air, flex 5 Comments
8Jul/091

Pixel art by Kristof

You might wonder who created the pixel version of myself that you can admire on the right. It certainly was not me. All credits go to Kristof Saelen who has the difficult job at Nascom to create a pixel version of every employee. We use this avatar for email signatures, business cards and I like it so much that I already have a second version of my pixelpeep.

Check out some of his latest work. It's pretty cool:

Tribute to Michael Jackson by Kristof Saelen

Tour de France Heroes by Kristof Saelen

UPDATE: the pixels got their own site called VIPs * Very Important Pixels. You better check it out for more creations.

Filed under: nascom 1 Comment