Archive

Author Archive

Automation testing with Flex Monkey (Reloaded) and Maven

August 8, 2011 Leave a comment

Lately there are lot of questions on the flex monkey forum running the functional testing with maven. However there are more questions related to converting the ant script into maven stuff.

Thought of posting the steps that we use to run the automated testing with maven.

Create a maven profile to run the automation tests only when you need that. This will obviously save some time when you dont need to run each time, since you are not running it part of the maven build lifecycle.  More information on build profiles can be found at this link

Maven-antrun-plugin provides the ability to run ant tasks from maven.

 <profile>
<id>automate</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>

<tasks unless=”maven.test.skip”>
<delete file=”${basedir}/automation/build.properties”/>
<copy file=”${basedir}/automation/build.local.properties”
tofile=”${basedir}/automation/build.properties”/>
<ant antfile=”${basedir}/automation/build.xml”>
</ant>
</tasks>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.7.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-optional</artifactId>
<version>1.5.3-1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-apache-xalan2</artifactId>
<version>1.8.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>

</build>
</profile>

If you see the above code, it runs the antfile “build.xml” which is in automation folder. The build.properties are the files which is needed for my application to set the channel end points ( channel Endpoint url are different for  development, scrum, qa and also for prod). The configurations can be used to override the properties file used by ant to change the channel configuration.

There are many ways to dymanically change the channel configuration run-time by loading xmls.., changing serverconfig data and also by changing the services-config url as well etc..,

The libraries which are added in dependency section are need to generate the Junitreport tasks.

If you run the build.xml within flex builder, it would run the “junitreport” task without any issue. Since it would use the built-in jar available within flash builder plugins sections. But when running with maven, you need the above dependencies artifacts (ant , ant-optional and ant-apache-xalan2) for the report generation to work.

Here is the core part of the build XML which is used to run the generated flex unit tests (either recorded ones as well by flex monkey)

    <target name=”execute_test” depends=”initTest”>
<echo>${build.dir}/${main}.swf</echo>
<flexunit
url=”file://${build.dir}/${main}.swf”
command=”${monkey.launch.app}”
toDir=”${report.dir}”
haltonfailure=”false”
verbose=”true” />

<echo message=”Flex Monkey reports are generated to ${report.dir}” />

<junitreport todir=”${report.dir}”>
<fileset dir=”${report.dir}” >
<include name=”TEST-*.xml”/>
</fileset>
<report format=”frames”  todir=”${report.dir}/html”/>
</junitreport>
</target>

Curious to know if there is any effective way to run automated testing for your flex apps. Please could you mention that in comments section.

Categories: Flex, Flex monkey, Testing

Flash JSFL Utility

November 12, 2010 Leave a comment

Back to Flash world after long time. Everything is good.

I found this utility useful especially when working with multiple fla;s which needs to exported on every time when launching the game. Everything goes fine, until there is an compile time error while launching. If there’s one, then launching the game with errors seems of no use.

The Flash JSFL utility does by checking for errors., There is no direct way( Not sure if there;s one atleast as per my knowledge, if there’s some hacky way of getting around please post that in comments), so reading the output of the compile panel and saving it to a text file , reading that text file contents and checking if there is any error or warning against that output.

If there’s no error flash would output in certain way like

0 Error(s), 0 Warning(s)

Right here were the steps to get into that

var exportSWFs=new Array();

exportSWFs.push(gameManager);

exportSWFs.push(game);

exportSWFs.push(logo);

Push your sequence of swf’s into an array. The gameManager could be of an array with values formed from source path of the fla and destination where the swf needs to be published.

for (var i = 0; i < exportSWFs.length; i++)

{

var documentObj= fl.openDocument(exportSWFs[i][0]);

documentObj.exportSWF(exportSWFs[i][1],true);

// creating a file name based on document

var docErrorURI= logDirURI + documentObj.name + “.errors”

// saving the contents of the errors

fl.compilerErrors.save(docErrorURI);

// reading the contents of the error from file

var contents = FLfile.read(docErrorURI);

// If there is no errors and warnings , it prints out like 0 Error(s), 0 Warning(s)

// getting errorCount from the above output; Not sure if regular expression works here

var errorCount = (contents.split(“Error(s)”)[0]).split(”)[(contents.split(“Error(s)”)[0]).length-2];

FLfile.remove(docErrorURI);

if (errorCount != “0”) {

// Dont want to continue with rest of export — I dont want to compile the fla with errors

success = false; break;

} }

if (success) {

// Do launch game here

}else{

alert(“There were errors in ” + documentObj.name);

}

Categories: Error, JSFL

Flash Builder IDE Bug

May 19, 2010 3 comments

Itsbeen pretty busy time, since moving onto flex4. There were lot of cool features and other stuffs currently working on and its exciting to learn new stuffs daily on work. I am working on some projects which shares the common code base, say a framework. I use flash builder with all those projects in my workspace, so that it would be easy to switch to different projects in the same localdrive workspace. The problem i have been encountering with the Flash builder IDE, was getting the file opened which is on my [Source path]. I tried refreshing, Cleaning up the project, but of no use. The only work around for this bug was to close and open the Flash Builder IDE to get it work.

Hopefully, will update this blog again with the right solution to overcome this bug sooner.

Categories: Flash Builder

Label HtmlText in Flex

January 7, 2010 1 comment

While working on some stuffs with related to htmltext using some styles for Label, it seems to be not displaying the text.

Here were the some sample scripts denoting the error which i encountered

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml&#8221;
initialize=”init()”
layout=”vertical”>
<mx:Label>
<mx:htmlText>
<![CDATA[
Label text goes here
]]>
</mx:htmlText>
</mx:Label>

</mx:Application>

It might seems to be fine with the above code, but it wont display the text, since the text entered in the CDATA section is on the second line. While working on stuffs with various html tags inside the same line, it might be very hard to figure out this silly mistakes sometimes.

The working version of the above staments would need to be like this

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml&#8221;
initialize=”init()”
layout=”vertical”>
<mx:Label>
<mx:htmlText>
<![CDATA[Label text goes here]]>
</mx:htmlText>
</mx:Label>

</mx:Application>

I guess it should be a IDE enhancement stuff when using htmlText inside Label, the cursor should default to be on the first line of the CDATA section of the Label control.(The Label control is a noneditable single-line text label)

Categories: Components, Flex

ArgumentError: Error #2082: Connect failed because the object is already connected.

December 1, 2009 1 comment

Using Flash localconnection i encountered a weird bug today while working on a project connecting AS2 and AS2 SWFs.  Below is the error which i got while trying to connect to a localConnection channel.

ArgumentError: Error #2082: Connect failed because the object is already connected.
at flash.net::LocalConnection/connect()
at com.gskinner.utils::SWFBridgeAS3/connect()
at com.orbis.bridges::TopbarBridgeAS3/connectBridge()
at com.orbis.ui.topbar::FauxF8TopBar/connectBridge()
at com.orbis.game::GameLaunchEntry/allAssetsLoaded()
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.orbis.load::Preloader/somethingLoaded()
at com.orbis.load::LoadContent/thisLoaded()

I forcefully quit the Flash IDE while flash player crashed due to loading of huge amount of data via XML for testing certain scenario in the game. That was the cause of the problem, there seems to be some player instance still on.  To more clearer, i was using Flash IDE  not a browser. Finally of no choice i have to restart the system and try to get this sorted out.

After that it works fine. Weird one.. just eat up few mins of my morning time.  So to get clear detail about the bug, google to get few informations. You can find the informations on Judah’s blog and some more information here

Categories: Flash, localconnection

Slider :: Flex Mobile Framework

November 16, 2009 1 comment

I was occupied with lot of stuffs for the past months or so. So didnt had enough time to browse through the max videos nor the adobe labs page. There were some cool stuffs for mobile via slider, Flex Mobile Framework. You can read the FAQ and whitepaper for more understanding.

Categories: Flex, Mobile

Tween Class

November 16, 2009 Leave a comment

Today while working on AS3 project which uses Tween, encountered a weired issue which causes the Tween to Freeze. This could be a pretty old issue, anyways here were the issue that i encountered and also possible ways of resolving that.

The code that causing the issue was due to the Tween was stored in a local variable and the variable might be garbage collected before the completion of the scripted motion.

Tween Code which may cause Freeze (Buggy)

function someFunction()
{
var myTween:Tween= new Tween(myObject, “x”, Elastic.easeOut, 0, 300, 3, true);
myTween.addEventListener(TweenEvent.MOTION_FINISH, listenerFunction);
// …
}

To prevent the tween code that causes Freeze , Here were few steps that we can do

1. Storing the tween variable globally.

Even if there is an event listener registered for an object, the object may be garbage collected if it’s a local variable ( with the scope of a function). To prevent this, declare the variable globally as in the following.

var myTween:Tween;

function someFunction()
{
myTween = new Tween(myObject, “x”, Elastic.easeOut, 0, 300, 3, true);
myTween.addEventListener(TweenEvent.MOTION_FINISH, listenerFunction);
// …
}

(Took this from Flash documentation, it is weird the way Flash Performs Garbage collection L or I am missing something here?)

2.Using Tween to Keep Reference in the memory until the tween motion is completed, This can be achieved by using Dictionary class or using a custom class to manage the way tween is garbage collected.

Reference links

# Documentation

# Adobe bug base

Categories: Tween