Some days ago, I came across with FlexMonkey.
FlexMonkey is a unit testing framework for Flex apps that provides for automating the testing of Flex UI functionality. FlexMonkey can record and play back Flex UI interactions, and generates ActionScript-based testing scripts that can easily be included within a continuous integration process. It uses the Flex Automation API and was created by adapting Adobe’s sample application, AutoQuick.
So I decide to try it with flex-mojos. And figure out it works, but, need some preparation.
With you wanna do that too, I first suggest you to take a look on FlexMokey quick tutorial here.
FlexMokey uses flex automation, so, we need to make it available at maven repository. So let’s start installing flexbuilder FDK at maven repo. For that task we use the install-mojo:
mvn info.flex-mojos:install-mojo:install-sdk -Dflex.sdk.folder=${your path to flexbuilder}/sdks/3.1.0 -Dversion=3.1.0-fb3
I call it 3.1.0-fb3. Because I don’t wanna to confuse with mpl version available at flex-mojos repo. I suggest you do the same.
Another dependency we need at maven repo is the flex monkey itselft. So, download this zip (or any newest), unpack somewhere and install it using maven install-file:
mvn install:install-file -DgroupId=com.gorillalogic -DartifactId=flexmonkey -Dversion=0.2b -Dpackaging=swc [-DgeneratePom=true] -Dfile=${unpack.folder}/MonkeyExample/libs/FlexMonkey.swc
I’m using this ids (groupId and artifactId) as personal guess. May be project authors can one day start to use maven and change it. So far they don’t. The parameter under [] is not required. But is good to have, avoid get maven trying to download this pom each time you compile the project.
Now we must create a pom.xml. Like this one:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>info.flex-mojos.samples</groupId>
<artifactId>flexmonkey-sample</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>swf</packaging>
<build>
<sourceDirectory>src</sourceDirectory><!-- I don't wanna change MonkeyExample project -->
<resources>
<resource>
<directory>resources</directory><!-- need a resouces directory to FlexMonkeyEnv.xml -->
</resource>
</resources>
<plugins>
<plugin>
<groupId>info.flex-mojos</groupId>
<artifactId>flex-compiler-mojo</artifactId>
<version>2.0M8-SNAPSHOT</version> <!-- need to use TRUNK -->
<extensions>true</extensions>
<configuration>
<locales>
<locale>en_US</locale>
</locales>
<includes>
<include>test.FlexUnitTests</include>
</includes>
</configuration>
</plugin>
<plugin>
<!-- get FlexMonkeyEnv.xml copyed -->
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>flex-mojos-repository</id>
<url>http://svn.sonatype.org/flexmojos/repository/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>flex-mojos-repository</id>
<url>http://svn.sonatype.org/flexmojos/repository/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>com.adobe.flex.framework</groupId>
<artifactId>flex-framework</artifactId>
<version>3.1.0-fb3</version>
<type>pom</type>
</dependency>
<dependency> <!-- I'm guessing this IDs -->
<groupId>com.gorillalogic</groupId>
<artifactId>flexmonkey</artifactId>
<version>0.2b</version>
<type>swc</type>
<scope>internal</scope>
</dependency>
<!--
Automation dependencies, already added by flex-framework, but need to
change the scope
-->
<dependency>
<groupId>com.adobe.flex.framework</groupId>
<artifactId>automation</artifactId>
<version>3.1.0-fb3</version>
<type>swc</type>
<scope>internal</scope>
</dependency>
<dependency>
<groupId>com.adobe.flex.framework</groupId>
<artifactId>automation_agent</artifactId>
<version>3.1.0-fb3</version>
<type>swc</type>
<scope>internal</scope>
</dependency>
<!-- flexunit dependencies -->
<dependency>
<groupId>flexunit</groupId>
<artifactId>flexunit</artifactId>
<version>0.85</version>
<type>swc</type>
<scope>internal</scope>
</dependency>
<dependency>
<groupId>flexunit.junit</groupId>
<artifactId>flexunit-optional</artifactId>
<version>0.85</version>
<type>swc</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>
The last step is to copy FlexMonkeyEnv.xml from flexmonkey to resouces folder. That folder don’t exists, must be created.
Now you should be able to run maven:
mvn clean package [or install]
Double click on flexmonkey-sample-1.0-SNAPSHOT.swf should show Monkey Contact Manager with Flex Monkey panel. Like this.
So a fast check list.
Install FLEX SDK using install-mojo
Install FlexMonkey using maven install-file
Create pom.xml
Copy FlexMonkeyEnv.xml to resouces folder
My final project is available here.
So far so good, but, the application is not tested at maven build. How do we do that? I don’t know that! Yet. Anyone wanna help?
VELO
Tags: Flex by velo
6 Comments »