পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Friday, February 17, 2017

Flex - FlexUnit Integration

Flash Builder 4 excellent inbuilt support for FlexUnit integration in Flex development Cycle.

Create a Test Case Class

You can create a Test Case Class using Flash Builder Create Test Class wizard. Running test cases is a breeze with Flash Builder as you will see in this article.

To create a test case class using Flash Builder, Click on File > New > Test Case Class. Enter the details as shown below.
Flex Test Case Class Flash Builder will create the following TestClass1.as file.
package com.tutorialspoint.client
{
   public class TestClass1
   {  
      [Before]
      public function setUp():void {}

      [After]
      public function tearDown():void {}

      [BeforeClass]
      public static function setUpBeforeClass():void {}

      [AfterClass]
      public static function tearDownAfterClass():void {} 
   }
}

FlexUnit Integration Example

Now Let us follow the following steps to test FlexUnit Integration in a Flex application:
StepDescription
1Create a project with a name HelloWorld under a package com.tutorialspoint.client as explained in the Flex - Create Application chapter.
2Modify HelloWorld.mxml as explained below. Keep rest of the files unchanged.
3Create TestClass1.as test case as described above and Modify TestClass1.as as explained below.
4Compile and run the application to make sure business logic is working as per the requirements.
Following is the content of the modified as file src/com.tutorialspoint/client/TestClass1.as.
package com.tutorialspoint.client
{
   import org.flexunit.asserts.assertEquals;

   public class TestClass1
   {  
      private var counter: int = 1;

      [Before]
      public function setUp():void
      {
         //this code will run before every test case execution
      }

      [After]
      public function tearDown():void
      {
         //this code will run after every test case execution
      }

      [BeforeClass]
      public static function setUpBeforeClass():void
      {
         //this code will run once when test cases start execution
      }

      [AfterClass]
      public static function tearDownAfterClass():void
      {
         //this code will run once when test cases ends execution
      }      

      [Test]  
      public function testCounter():void { 
         assertEquals(counter, 1);
      }
   }
}
Following is the content of the modified mxml file src/com.tutorialspoint/HelloWorld.mxml.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
   xmlns:s="library://ns.adobe.com/flex/spark" 
   xmlns:mx="library://ns.adobe.com/flex/mx" 
   minWidth="500" minHeight="500">
</s:Application>
Once you are ready with all the changes done, let us compile in normal mode as we did in Flex - Create Application chapter.

Running Test cases

Now Right Click on TestClass1 in package explorer and select Run As > FlexUnit Tests. You'll see the following output in Flash Builder test window.
flex FlexUnit Result Flash Builder also show test result in the browser.
flex FlexUnit Result1

No comments:

Post a Comment