Showing posts with label Flex. Show all posts
Showing posts with label Flex. Show all posts

Saturday, November 17, 2007

FunFX - Getting started

At the website for FunFX at Rubyforge, there are some old direction on how to get started with FunFX. I will now make a better up-to-date getting started with FunFX (and hopefully get to update the website).

The first thing you need is to get Flex Builder from Adobe, and the FunFX zip file located at Rubyforge. The FunFX zip file contains three files;
  • AutomationGenericEnv.xml
  • FunFXAdapter.swc
  • FunFX-0.0.x.gem.
To get things to workyou will need additional three files, but they are part of the Flex 3 SDK (with Flex 2 SDK these files are bundled with Flex Data Services and the automation package, but you will be able to get the files from Flex 3 SDK) ;
  • automation_agent_rb.swc
  • automation_agent.swc
  • automation.swc.
The automation_agent_rb.swc must be located in the language folder in use in the locale folder. In the Flex SDK 3 version this file is already in place in the correct folder.

The FunFX gem file must be installed locally on your computer. It does not exist in any public repository yet, so you must choose the local gem file located in the FunFX zip file.

All the other files will be used when creating the Flex project, which I will begin explaining now. I will explain using Eclipse as the IDE.

Creating a new Flex Project
The first thing is to create the Flex project of choice. Then you must add the AutomationGenricEnv.xml to the root path of the project or just add it directly to the bin catalog or the output folder of choice. The adapter uses this file to build the automation environment of all display objects.

To be able to take advantage of the FunFXAdapter file you must add it as a compiler option as shown in the picture below. The adapter is relying on the files automation_agent.swc and the automation.swc files, and thus they must also be added as a compiler option.

I have tried to add these swc files as swc files in the build path but this does not work. I am not really sure why this is, so if anybody has any comments on this fact please let me know.



Now your application is ready to be tested. Remember to be consistent with giving all your display object uniq id's and the testing will be more efficient.

At the end of this post it is an important notice I have to give, and that is about different versions of Flex SDK's. It seems that Flex projects does not like swc files that is compiled with different SDK versions. Due to this the precompiled versions of the FunFXAdapter.s that is supplied with the FunFX zip file might not work with your application (the version out now ,FunFX version 0.0.2 is compiled with Flex SDK version 3.0.0). If this happens download the source code and compile your own version.

I hope this post will help you get started with FunFX, allthough I know I have not talked about how to write the actual tests. The next post will talk about how to write these tests with Ruby.

FunFX - The background

FunFX is a framework for funcional testing of Adobe Flex applications. This post will talk about the background for this tool and some on the implementation decisions.

According to Wikipedia, Adobe Flex is a collection of technologies released by Adobe Systems for the development and deployment of cross platform, rich Internet applications based on the proprietary Adobe Flash platform.

FunFX was initiated by Bekk Consulting in desember 2006 as a master thesis at the Norwegian University of Science and Technology. This was due to Flex's lack of a proper tool for automated functional testing. The only tool was Mercury's Quick Test Professional, which does not support TDD and cost a whole lot of money. We wanted to create an open source version that would support TDD.

I began the work on this framework January 2007, and did not have a lot of experience with Flex. I decided to use Ruby as the language for the actual framework for writing the test scripts.

The first initial problem and the most critical part of this framework was how to be able to talk to the Flex application and make it replay certain events. After some starting tips from Matt Chotin, Sreenivas Ramaswamy, and Matt Horn from Adobe, I decided to use the ExternalInterface API. This enabled me to expose certain "generic" methods out, enabling Ruby scripts to make calls into the Flex application.

I built a Flex library file that acts as an adapter between a Flex application and the Ruby tests. The Ruby framework is dynamically built from an XML file delivered by Adobe that describes all the different display objecs and their events and properties. This makes it possible to write test lines as the following:

@ie.button("name").click
@ie.button("name").label

When running the Ruby script the adapter will try to find a display object by the type button with the name "name" and run either the click event or delivering the lebel text of the button.

The Ruby framework uses the WIN32OLE to drive an Internet Explorer window and the Flex application displayed.

There are currently no support for other browsers or to test a Flex application in the Flash player.

The next post will help getting started with FunFX.