Testing Flex RIAs  Viktor Gamov, Farata Systems         April, 27 2011
Agenda•   Why to test?•   Automation testing and tools overview•   Flex Automation 101    •   Flex Automation Framework bu...
Why to test?
Software Has Bugs•   We want to minimize the number, and•   We want change to safe•   How?
Only person who can write code       without bugs is ...
Only person who can write code       without bugs is ...
Why Chuck Norris does not test?
Why Chuck Norris      does not test?•   His code is perfect
Why Chuck Norris      does not test?•   His code is perfect•   He does not need code documentation and    communication on...
Why Chuck Norris      does not test?•   His code is perfect•   He does not need code documentation and    communication on...
Why Chuck Norris      does not test?•   His code is perfect•   He does not need code documentation and    communication on...
Testing Flex RIAs
Testing Flex RIAs•   Unit testing
Testing Flex RIAs•   Unit testing•   Functional (UAT,    QA)testing
Testing Flex RIAs•   Unit testing•   Functional (UAT,    QA)testing•   Integration testing
Testing Flex RIAs•   Unit testing•   Functional (UAT,    QA)testing•   Integration testing•   Load testing
Automation testingtools overview•   QTP•   Selenium•   Ranorex•   FlexMonkey
QTPPros:•   All-in-one suite for automation testing    enterprise applications•   Supports large pool of  software develop...
QTPCons:•   Unstable work•   Absence of IDE for debugging scripts•   Only Windows and IE (sorry Mac and Linux•   VBScript ...
Selenium + Flex API•   Web applications testing•   Open source and large community•   Cross platform (Selenium IDE - brows...
Ranorex•   Similar to QTP, but better•   Support large amount supported technologies    (.NET, WPF, Silverlight, Qt, Win32...
FlexMonkey•   OpenSource (commercial support available)•   Flex apps testing centric tool•   Cross platform (console - AIR...
The process of creating a customcomponent that supports automatedtesting is called instrumentation
Flex Automation 101
Component delegate•   instance of delegate class gets added for each instance    of components•   delegates know about the...
Automation Flow   Core Flex API                    SystemManager                                        Automation   Deleg...
Flex AutomationFramework building blocks•   Component delegate (automation.swc,    automation_dmv.swc ...., custom classes...
[Mixin] metadata tag•   use is to create static code blocks to initialize    parts of your application•   that static code...
[Mixin] exampleimport mx.managers.ISystemManager;//---------------------------------------------------// Example//--------...
How to prepare your  components for automation testing
What is a custom        component•   A component extending from a standard    component (No additional events, no    addit...
What to do in delegate    if component extending from standard component•   Nothing! Use delegate classes shipped with    ...
What to do in delegateif component extending from standard component + additional                   events or properties• ...
What do in delegatecomponent extending from non container class, but the   current class need to be threaded as a containe...
Using FlexMonkey for   testing custom    components        Demo
Conclusion•   Testing is a very powerful tool to help    produce, maintain and impart confidence in    your software•   Act...
Resources•   Enterprise Development with Flex, O’reilly,    2010•   GorillaLogic http://clck.ru/BXV4•   Ranorex Flex Testi...
Thank you!Contact me!
Testing Flex RIAs for NJ Flex user group
Testing Flex RIAs for NJ Flex user group
Upcoming SlideShare
Loading in...5
×

Testing Flex RIAs for NJ Flex user group

568

Published on

Why to test?
● Automation testing and tools overview
● Flex Automation 101
○ Flex Automation Framework building blocks ○ How to prepare you components for
automation testing
● Using FlexMonkey for testing custom
components

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
568
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Why Chuck does not write the tests?\n\nThis code is perfect\n\nIn the code, Chuck Norris never bugs. He is never wrong. If you find a bug in the code, Chuck - try to talk to him about it - just realize that it really necessary feature of the project.\n\nIt does not need code documentation and communication on the project\n\nIn fact, the documentation - this is just one way communication. Documenting code, we are dealing with a team (with the present and future), which works on the project. Tests - this is the best documentation. Paper documentation, developers do not read, and disappear somewhere, these papers and files all the time. In written comments to the code is not always possible to understand - what exactly meant by the author. In the same tests immediately clear how the code works, what he should do to get.\nChuck this is not necessary - he has one.\n\nPerfect Memory\n\nOn what projects you can work alone? Only those where you bought a plane ticket into a warm country where the customer you will not find. On all other projects you are working at least two people - you and you in the future. And you need to communicate with itself for implementation. Chuck manages fine without it - he remembers everything in their projects.\n\nRefactoring without problems\n\nChuck did not do the refactoring because his code right ideal. So what of situations where you need something to change or optimize and try not to break anything in the process, he just does not happen.\n\n
  • Why Chuck does not write the tests?\n\nThis code is perfect\n\nIn the code, Chuck Norris never bugs. He is never wrong. If you find a bug in the code, Chuck - try to talk to him about it - just realize that it really necessary feature of the project.\n\nIt does not need code documentation and communication on the project\n\nIn fact, the documentation - this is just one way communication. Documenting code, we are dealing with a team (with the present and future), which works on the project. Tests - this is the best documentation. Paper documentation, developers do not read, and disappear somewhere, these papers and files all the time. In written comments to the code is not always possible to understand - what exactly meant by the author. In the same tests immediately clear how the code works, what he should do to get.\nChuck this is not necessary - he has one.\n\nPerfect Memory\n\nOn what projects you can work alone? Only those where you bought a plane ticket into a warm country where the customer you will not find. On all other projects you are working at least two people - you and you in the future. And you need to communicate with itself for implementation. Chuck manages fine without it - he remembers everything in their projects.\n\nRefactoring without problems\n\nChuck did not do the refactoring because his code right ideal. So what of situations where you need something to change or optimize and try not to break anything in the process, he just does not happen.\n\n
  • Why Chuck does not write the tests?\n\nThis code is perfect\n\nIn the code, Chuck Norris never bugs. He is never wrong. If you find a bug in the code, Chuck - try to talk to him about it - just realize that it really necessary feature of the project.\n\nIt does not need code documentation and communication on the project\n\nIn fact, the documentation - this is just one way communication. Documenting code, we are dealing with a team (with the present and future), which works on the project. Tests - this is the best documentation. Paper documentation, developers do not read, and disappear somewhere, these papers and files all the time. In written comments to the code is not always possible to understand - what exactly meant by the author. In the same tests immediately clear how the code works, what he should do to get.\nChuck this is not necessary - he has one.\n\nPerfect Memory\n\nOn what projects you can work alone? Only those where you bought a plane ticket into a warm country where the customer you will not find. On all other projects you are working at least two people - you and you in the future. And you need to communicate with itself for implementation. Chuck manages fine without it - he remembers everything in their projects.\n\nRefactoring without problems\n\nChuck did not do the refactoring because his code right ideal. So what of situations where you need something to change or optimize and try not to break anything in the process, he just does not happen.\n\n
  • Why Chuck does not write the tests?\n\nThis code is perfect\n\nIn the code, Chuck Norris never bugs. He is never wrong. If you find a bug in the code, Chuck - try to talk to him about it - just realize that it really necessary feature of the project.\n\nIt does not need code documentation and communication on the project\n\nIn fact, the documentation - this is just one way communication. Documenting code, we are dealing with a team (with the present and future), which works on the project. Tests - this is the best documentation. Paper documentation, developers do not read, and disappear somewhere, these papers and files all the time. In written comments to the code is not always possible to understand - what exactly meant by the author. In the same tests immediately clear how the code works, what he should do to get.\nChuck this is not necessary - he has one.\n\nPerfect Memory\n\nOn what projects you can work alone? Only those where you bought a plane ticket into a warm country where the customer you will not find. On all other projects you are working at least two people - you and you in the future. And you need to communicate with itself for implementation. Chuck manages fine without it - he remembers everything in their projects.\n\nRefactoring without problems\n\nChuck did not do the refactoring because his code right ideal. So what of situations where you need something to change or optimize and try not to break anything in the process, he just does not happen.\n\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • The SystemManager class creates the display list, a tree of visible objects that make up your application.\nEach time a new component is added, either at the root of the display list or as a child of another member of the display list, SystemManager dispatches an Event.ADDED event.\nThe AutomationManager listens for the ADDED event. In its ADDED event handler, it calls methods on the Automation class. It then instantiates the delegate for that class.\nThe Automation class maps each component in the display list to its full class name.\nWhen it is created, the delegate class adds a reference to its instance in the delegate class map. The delegate class then handles events during record and play-back sequences.The delegate is now considered registered with the component. It adds event listeners for the component’s events and calls the AutomationManager when the component triggers those events.\nAfter the components in the display list are instantiated and mapped to instances of their delegate classes, the AutomationManager is ready to listen for events and forward them to the agent for processing.\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • E.g. user creates an MyAdvancedDataGrid extending from AdvancedDataGrid.\n i.e no special user interaction possibilities on it other than the base component.\nE.g. user creates MyComponent extending from Panel and have some controls in it. \ni.e the new component is a container, and the base also a container. \nWhat to do here? \nNothing. The base component automation (delegate) will take care of the needed. \n\n
  • E.g. user creates an MyAdvancedDataGrid extending from AdvancedDataGrid.\n and there is a new event which needs to be recorded.\nUser extends from a component, but wishes to expose a behavior which is different \nfrom that of the standard component.\nWhat to do ?\nCreate a new Delegate\nAdd in the new delegate to the application using -includes\nProvide the details of the component in the XML file\n\n\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Testing Flex RIAs for NJ Flex user group

    1. 1. Testing Flex RIAs Viktor Gamov, Farata Systems April, 27 2011
    2. 2. Agenda• Why to test?• Automation testing and tools overview• Flex Automation 101 • Flex Automation Framework building blocks • How to prepare you components for automation testing• Using FlexMonkey for testing custom components
    3. 3. Why to test?
    4. 4. Software Has Bugs• We want to minimize the number, and• We want change to safe• How?
    5. 5. Only person who can write code without bugs is ...
    6. 6. Only person who can write code without bugs is ...
    7. 7. Why Chuck Norris does not test?
    8. 8. Why Chuck Norris does not test?• His code is perfect
    9. 9. Why Chuck Norris does not test?• His code is perfect• He does not need code documentation and communication on the project
    10. 10. Why Chuck Norris does not test?• His code is perfect• He does not need code documentation and communication on the project• Perfect memory
    11. 11. Why Chuck Norris does not test?• His code is perfect• He does not need code documentation and communication on the project• Perfect memory• Refactoring without problems
    12. 12. Testing Flex RIAs
    13. 13. Testing Flex RIAs• Unit testing
    14. 14. Testing Flex RIAs• Unit testing• Functional (UAT, QA)testing
    15. 15. Testing Flex RIAs• Unit testing• Functional (UAT, QA)testing• Integration testing
    16. 16. Testing Flex RIAs• Unit testing• Functional (UAT, QA)testing• Integration testing• Load testing
    17. 17. Automation testingtools overview• QTP• Selenium• Ranorex• FlexMonkey
    18. 18. QTPPros:• All-in-one suite for automation testing enterprise applications• Supports large pool of  software development environments like SAP , Web , Oracle etc.• QTP is easier to use and implement for both technical & non technical testers• Support libraries out-of-the-box with Flex(qtp.swc, qtp_air.swc)
    19. 19. QTPCons:• Unstable work• Absence of IDE for debugging scripts• Only Windows and IE (sorry Mac and Linux• VBScript as scripting language• Not free and expensive
    20. 20. Selenium + Flex API• Web applications testing• Open source and large community• Cross platform (Selenium IDE - browser extension)• JavaScript as scripting language
    21. 21. Ranorex• Similar to QTP, but better• Support large amount supported technologies (.NET, WPF, Silverlight, Qt, Win32, Delphi, WFC, Java SWT, Web testing, Flash/Flex testing) and platforms• Script languages C#,VB.NET, IronPython• Integration with Visual Studio 2010• Platform: Windows• Not free, ~$1590 for one license (full suite)
    22. 22. FlexMonkey• OpenSource (commercial support available)• Flex apps testing centric tool• Cross platform (console - AIR application )• Generated FlexUnit 4 test code• Supports testing only Flex applications (no Flash)• Integration with Selenium IDE (FlexMonkium project)
    23. 23. The process of creating a customcomponent that supports automatedtesting is called instrumentation
    24. 24. Flex Automation 101
    25. 25. Component delegate• instance of delegate class gets added for each instance of components• delegates know about the component which associated• adds listeners to interested events of component• decides what to do when an event occurs and calls appropriate method on Automation Manager• can provide additional methods which will be interested for testers
    26. 26. Automation Flow Core Flex API SystemManager Automation Delegates Automation API Automation Manager Delegates Delegates QTP FlexMonkey Selenium Agent Classes Agent Agent Agent Automation Tools QTP FlexMonkey Selenium
    27. 27. Flex AutomationFramework building blocks• Component delegate (automation.swc, automation_dmv.swc ...., custom classes )• Automation Manager (automation_manager.swc)• Tool Adapter (automation_monkey4.x.swc)• Testing Tool (FlexMonkey Console)• Environment configuration
    28. 28. [Mixin] metadata tag• use is to create static code blocks to initialize parts of your application• that static code will be executed when a preloader finishes loading of the application class and the SystemManager is ready to kick off [2 frame]
    29. 29. [Mixin] exampleimport mx.managers.ISystemManager;//---------------------------------------------------// Example//---------------------------------------------------[Mixin]public class MyMixin{ /** * called due to the fact that ive used the [Mixin] metatag * @param systemManager */ public static function init(systemManager:ISystemManager):void { // do something }}
    30. 30. How to prepare your components for automation testing
    31. 31. What is a custom component• A component extending from a standard component (No additional events, no additional properties)• A component extending from a standard component – Additional events/ additional properties• A component extending from a non container class, but the current class is a container.
    32. 32. What to do in delegate if component extending from standard component• Nothing! Use delegate classes shipped with Flex Framework
    33. 33. What to do in delegateif component extending from standard component + additional events or properties• Add Event listener to interesting event• Identify the details of the event which is needed to reply the event later• Pass event to record to automation manager• handle reply of the event
    34. 34. What do in delegatecomponent extending from non container class, but the current class need to be threaded as a container • Expose required children • getAutomationChildren • getAutomationChildAt • get numAutomationChildren • Provide the child handler methods • createAutomaitonIDPart • resolveAutomationIDPart • createAutomationIDPartWithRequiredProperties
    35. 35. Using FlexMonkey for testing custom components Demo
    36. 36. Conclusion• Testing is a very powerful tool to help produce, maintain and impart confidence in your software• Actionscript 3 now has testing tools approaching the level available to Java developers• We should all be testing!
    37. 37. Resources• Enterprise Development with Flex, O’reilly, 2010• GorillaLogic http://clck.ru/BXV4• Ranorex Flex Testing http://clck.ru/BXUk• Automation Docs http://clck.ru/Bqbn• Blog on Flex Automation http://clck.ru/BqbU
    38. 38. Thank you!Contact me!
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×