BTA Flexing

My passion RIAs…………..Shardul Singh Bartwal

Unit Testing in Flex 4 application Using Flash-Builder 4

Posted by Shardul Singh Bartwal on June 30, 2011

Inside the Flash builder 4 simply create a new Flex project,I am naming it as UnitTestingDemo.
1)I have created a class with name under the folder the utils,I am putting it inside the utils just for practice.
Which is as below:-

package utils
public class MyMath
public function MyMath()

public function add(num1 : Number,num2 : Number) : Number
return num1 + num2;

public function multiply(num1 : Number,num2 : Number) : Number
return num1 * num2;

2)Now go to File>New>Test Case Class


3)Now I am createing a class with name MyTestCase1. See below:-

Click on the Browser button.

4)It will look as :-
Select the MyMath and click OK as below:-

Now it should look like:-

click on Next button.You will see like below:-

Click Finish.

5)Now on the Package Explorer on the left you will under the folder flexUnitTests.You will see there a method with name testAdd() inside this class.

Now I am going to check for my expected positive result from this method.As we know that 5+6=11.So I have written like this inside this method:-

var myMath : MyMath = new MyMath();

6)Now Click on the and select it on the left side Package Explorer.Right Mouse click on this.You will see there a menu with title ‘Execute Flex UnitTests’ click on this.If every thing goes well you will see like below in your browser:-


Except this inside flash builder you will see a tab with title ‘FlexUnit Results’ Explore this for detail investigation.

Enjoy Flexing………….. 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: