SlideShare ist ein Scribd-Unternehmen logo
1 von 36
Downloaden Sie, um offline zu lesen
Automated User Tests
with Apache Flex
Gert Poppe
@gert789
About me
A Belgian consultant working at
Stack & Heap.
A passionate RIA developer.
A ZEND certified PHP Engineer.
A huge fan of the Randori Framework.
What are we talking about?
Wikipedia says:
... test automation is the use of special
software (separate from the software being
tested) to control the execution of tests and the
comparison of actual outcomes to predicted
outcomes. Test automation can automate some
repetitive but necessary tasks in a formalized
testing process already in place, or add
additional testing that would be difficult to
perform manually ...
Why should you bother?
● Efficiency
● More complete error reports
● Huge time savings
● A more complete code coverage
Why did we bother?
While taking over an existing project
● Huge and complicated code base
● No existing unit tests
● Complaints by users:
○ a lot of bugs in the GUI
○ a lot of recurrent bugs
How did we start?
External testing tool
Selenium
A suite of tools to automate your web
browser.
External Interface
communication between your browser
and the Flash Player.
● Java Test
○ Selenium for Java
○ Standalone Selenium server
○ FlexiumLink and FlashSelenium
● Flex Application
○ Flexium
https://github.com/StackAndHeap/flexium
The Selenium setup
DEMO
Available on our github
https://github.com/StackAndHeap/flexium
public Boolean click(String objectId) throws Exception {
delay();
if(isReady()) {
String result = call("doFlexClick", objectId, "");
return checkResult(result);
}
return false;
}
Under the hood - Selenium (1)
public Boolean click(String objectId) throws Exception {
delay();
if(isReady()) {
String result = call("doFlexClick", objectId, "");
return checkResult(result);
}
return false;
}
Under the hood - Selenium (1)
public Boolean click(String objectId) throws Exception {
delay();
if(isReady()) {
String result = call("doFlexClick", objectId, "");
return checkResult(result);
}
return false;
}
Under the hood - Selenium (1)
public Boolean click(String objectId) throws Exception {
delay();
if(isReady()) {
String result = call("doFlexClick", objectId, "");
return checkResult(result);
}
return false;
}
Under the hood - Selenium (1)
public Boolean click(String objectId) throws Exception {
delay();
if(isReady()) {
String result = call("doFlexClick", objectId, "");
return checkResult(result);
}
return false;
}
Under the hood - Selenium (1)
Under the hood - Selenium (2)
Under the hood - Selenium (3)
● Flexium
○ Compiles into your application
○ Parsing of your applications Stage
○ Registers your (custom) commands
Under the hood - Apache Flex (1)
Compiles into your application
... separate from the software being tested...
1) Use a Mixin
...
[Mixin]
public class Flexium extends Sprite {
...
Under the hood - Apache Flex (2)
Compiles into your application
... separate from the software being tested...
2) Include library
include-libraries library [...]
Under the hood - Apache Flex (2)
Parsing of your applications stage
Every component that gets added to the stage will be parsed by the
AS3-commons Stage Processing Library
http://as3commons.org/as3-commons-stageprocessing/index.html
Under the hood - Apache Flex (3)
Parsing of your applications stage with AS3Commons
private var _registry:FlashStageObjectProcessorRegistry;
private function initProcessor():void {
_registry = new FlashStageObjectProcessorRegistry();
_registry.useStageDestroyers = true;
_registry.registerStageObjectProcessor(
new EventDispatchingObjectProcessor(this),
new EventDispatchingObjectSelector()
);
_registry.initialize();
}
Under the hood - Apache Flex (4)
Parsing of your applications stage with AS3Commons
private var _registry:FlashStageObjectProcessorRegistry;
private function initProcessor():void {
_registry = new FlashStageObjectProcessorRegistry();
_registry.useStageDestroyers = true;
_registry.registerStageObjectProcessor(
new EventDispatchingObjectProcessor(this),
new EventDispatchingObjectSelector()
);
_registry.initialize();
}
Under the hood - Apache Flex (4)
Parsing of your applications stage with AS3Commons
private var _registry:FlashStageObjectProcessorRegistry;
private function initProcessor():void {
_registry = new FlashStageObjectProcessorRegistry();
_registry.useStageDestroyers = true;
_registry.registerStageObjectProcessor(
new EventDispatchingObjectProcessor(this),
new EventDispatchingObjectSelector()
);
_registry.initialize();
}
Under the hood - Apache Flex (4)
Parsing of your applications stage with AS3Commons
private var _registry:FlashStageObjectProcessorRegistry;
private function initProcessor():void {
_registry = new FlashStageObjectProcessorRegistry();
_registry.useStageDestroyers = true;
_registry.registerStageObjectProcessor(
new EventDispatchingObjectProcessor(this),
new EventDispatchingObjectSelector()
);
_registry.initialize();
}
Under the hood - Apache Flex (4)
Parsing of your applications stage with AS3Commons
public class EventDispatchingObjectSelector implements IObjectSelector {
public function approve(object:Object):Boolean {
return object is UIComponent;
}
}
Under the hood - Apache Flex (5)
Parsing of your applications stage with AS3Commons
public function process(displayObject:DisplayObject):DisplayObject {
_stageParser.addElement((displayObject as UIComponent).id, displayObject);
return displayObject;
}
public function destroy(displayObject:DisplayObject):DisplayObject {
_stageParser.removeElement((displayObject as UIComponent).id);
return displayObject;
}
Under the hood - Apache Flex (6)
Under the hood - Apache Flex (7)
Registers your (custom) commands
public class MouseAction extends AbstractAction implements IAction {
public function MouseAction(parser:StageParser) {
super(parser);
}
public function attachActions():void {
attach("click", doFlexClick);
}
public function doFlexClick(id:String, args:String):String {
var child:Object = parser.getElementById(id);
if (child == null) {
return Errors.OBJECT_NOT_FOUND;
}
return String(child.dispatchEvent(new MouseEvent(MouseEvent.CLICK)));
}
}
Under the hood - Apache Flex (7)
Registers your (custom) commands
public class MouseAction extends AbstractAction implements IAction {
public function MouseAction(parser:StageParser) {
super(parser);
}
public function attachActions():void {
attach("click", doFlexClick);
}
public function doFlexClick(id:String, args:String):String {
var child:Object = parser.getElementById(id);
if (child == null) {
return Errors.OBJECT_NOT_FOUND;
}
return String(child.dispatchEvent(new MouseEvent(MouseEvent.CLICK)));
}
}
Under the hood - Apache Flex (7)
Registers your (custom) commands
public class MouseAction extends AbstractAction implements IAction {
public function MouseAction(parser:StageParser) {
super(parser);
}
public function attachActions():void {
attach("click", doFlexClick);
}
public function doFlexClick(id:String, args:String):String {
var child:Object = parser.getElementById(id);
if (child == null) {
return Errors.OBJECT_NOT_FOUND;
}
return String(child.dispatchEvent(new MouseEvent(MouseEvent.CLICK)));
}
}
Under the hood - Apache Flex (7)
Registers your (custom) commands
public class MouseAction extends AbstractAction implements IAction {
public function MouseAction(parser:StageParser) {
super(parser);
}
public function attachActions():void {
attach("click", doFlexClick);
}
public function doFlexClick(id:String, args:String):String {
var child:Object = parser.getElementById(id);
if (child == null) {
return Errors.OBJECT_NOT_FOUND;
}
return String(child.dispatchEvent(new MouseEvent(MouseEvent.CLICK)));
}
}
Under the hood - Apache Flex (7)
Registers your (custom) commands
public class MouseAction extends AbstractAction implements IAction {
public function MouseAction(parser:StageParser) {
super(parser);
}
public function attachActions():void {
attach("click", doFlexClick);
}
public function doFlexClick(id:String, args:String):String {
var child:Object = parser.getElementById(id);
if (child == null) {
return Errors.OBJECT_NOT_FOUND;
}
return String(child.dispatchEvent(new MouseEvent(MouseEvent.CLICK)));
}
}
Under the hood - Apache Flex (7)
Registers your (custom) commands
public class MouseAction extends AbstractAction implements IAction {
public function MouseAction(parser:StageParser) {
super(parser);
}
public function attachActions():void {
attach("click", doFlexClick);
}
public function doFlexClick(id:String, args:String):String {
var child:Object = parser.getElementById(id);
if (child == null) {
return Errors.OBJECT_NOT_FOUND;
}
return String(child.dispatchEvent(new MouseEvent(MouseEvent.CLICK)));
}
}
FYI
● working with data
○ mock data
■ same result on every test
■ same result on every system
What's next?
● My way, not the highway...
● Custom components - custom commands
https://github.com/StackAndHeap/flexium/
QUESTIONS?
Twitter: @gert789
Email: gert.poppe@stackandheap.com

Weitere ähnliche Inhalte

Was ist angesagt?

Apache Ant
Apache AntApache Ant
Apache Ant
Ali Bahu
 
UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)
UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)
UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)
Tobias Schneck
 

Was ist angesagt? (19)

Hyper-pragmatic Pure FP testing with distage-testkit
Hyper-pragmatic Pure FP testing with distage-testkitHyper-pragmatic Pure FP testing with distage-testkit
Hyper-pragmatic Pure FP testing with distage-testkit
 
Izumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala StackIzumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala Stack
 
Introduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylightIntroduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylight
 
Agile Android
Agile AndroidAgile Android
Agile Android
 
Scala, Functional Programming and Team Productivity
Scala, Functional Programming and Team ProductivityScala, Functional Programming and Team Productivity
Scala, Functional Programming and Team Productivity
 
Going native with less coupling: Dependency Injection in C++
Going native with less coupling: Dependency Injection in C++Going native with less coupling: Dependency Injection in C++
Going native with less coupling: Dependency Injection in C++
 
QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
 
Apache Ant
Apache AntApache Ant
Apache Ant
 
UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)
UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)
UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)
 
Google C++ Testing Framework in Visual Studio 2008
Google C++ Testing Framework in Visual Studio 2008Google C++ Testing Framework in Visual Studio 2008
Google C++ Testing Framework in Visual Studio 2008
 
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and MockitoAn Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
 
What is new in JUnit5
What is new in JUnit5What is new in JUnit5
What is new in JUnit5
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
 
Quickly Testing Qt Desktop Applications
Quickly Testing Qt Desktop ApplicationsQuickly Testing Qt Desktop Applications
Quickly Testing Qt Desktop Applications
 
Integration Group - Lithium test strategy
Integration Group - Lithium test strategyIntegration Group - Lithium test strategy
Integration Group - Lithium test strategy
 
JUnit 5 - The Next Generation
JUnit 5 - The Next GenerationJUnit 5 - The Next Generation
JUnit 5 - The Next Generation
 
So how do I test my Sling application?
 So how do I test my Sling application? So how do I test my Sling application?
So how do I test my Sling application?
 
Take Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainersTake Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainers
 
Making the Most of Your Gradle Build
Making the Most of Your Gradle BuildMaking the Most of Your Gradle Build
Making the Most of Your Gradle Build
 

Andere mochten auch

Selenium IDE and Extensions
Selenium IDE and ExtensionsSelenium IDE and Extensions
Selenium IDE and Extensions
Yana Altunyan
 
Sakai10 Selenium Workshop
Sakai10 Selenium WorkshopSakai10 Selenium Workshop
Sakai10 Selenium Workshop
coreyjack
 
Steps to write Selenium
Steps to write Selenium  Steps to write Selenium
Steps to write Selenium
Rohit Thakur
 
Selenium Ide Tutorials
Selenium Ide TutorialsSelenium Ide Tutorials
Selenium Ide Tutorials
gueste1e4db
 
Jmeter Performance Testing
Jmeter Performance TestingJmeter Performance Testing
Jmeter Performance Testing
Atul Pant
 

Andere mochten auch (15)

Selenium IDE and Extensions
Selenium IDE and ExtensionsSelenium IDE and Extensions
Selenium IDE and Extensions
 
Selenium Training
Selenium TrainingSelenium Training
Selenium Training
 
Selenium
SeleniumSelenium
Selenium
 
Sakai10 Selenium Workshop
Sakai10 Selenium WorkshopSakai10 Selenium Workshop
Sakai10 Selenium Workshop
 
Steps to write Selenium
Steps to write Selenium  Steps to write Selenium
Steps to write Selenium
 
Selenium IDE and Beyond
Selenium IDE and BeyondSelenium IDE and Beyond
Selenium IDE and Beyond
 
Efficient Automated Test Creation With Selenium IDE Plugins
Efficient Automated Test Creation With Selenium IDE PluginsEfficient Automated Test Creation With Selenium IDE Plugins
Efficient Automated Test Creation With Selenium IDE Plugins
 
Apache Flex: Overview
Apache Flex: OverviewApache Flex: Overview
Apache Flex: Overview
 
Selenium Ide Tutorials
Selenium Ide TutorialsSelenium Ide Tutorials
Selenium Ide Tutorials
 
Selenium
SeleniumSelenium
Selenium
 
Testing Flex RIAs for NJ Flex user group
Testing Flex RIAs for NJ Flex user groupTesting Flex RIAs for NJ Flex user group
Testing Flex RIAs for NJ Flex user group
 
Selenium WebDriver FAQ's
Selenium WebDriver FAQ'sSelenium WebDriver FAQ's
Selenium WebDriver FAQ's
 
Jmeter Performance Testing
Jmeter Performance TestingJmeter Performance Testing
Jmeter Performance Testing
 
Java Basics for selenium
Java Basics for seleniumJava Basics for selenium
Java Basics for selenium
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 

Ähnlich wie Automated User Tests with Apache Flex

Kinect installation guide
Kinect installation guideKinect installation guide
Kinect installation guide
gilmsdn
 

Ähnlich wie Automated User Tests with Apache Flex (20)

MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 Slides:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
 
JCConf 2016 - Dataflow Workshop Labs
JCConf 2016 - Dataflow Workshop LabsJCConf 2016 - Dataflow Workshop Labs
JCConf 2016 - Dataflow Workshop Labs
 
React native
React nativeReact native
React native
 
Secure PHP environment
Secure PHP environmentSecure PHP environment
Secure PHP environment
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
 
Rewriting a Plugin Architecture 3 Times to Harness the API Economy
Rewriting a Plugin Architecture 3 Times to Harness the API EconomyRewriting a Plugin Architecture 3 Times to Harness the API Economy
Rewriting a Plugin Architecture 3 Times to Harness the API Economy
 
Plugins And Making Your Own
Plugins And Making Your OwnPlugins And Making Your Own
Plugins And Making Your Own
 
Php Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerPhp Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant Killer
 
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20Profiling PHP - AmsterdamPHP Meetup - 2014-11-20
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
Kinect installation guide
Kinect installation guideKinect installation guide
Kinect installation guide
 
Riga Dev Day - Automated Android Continuous Integration
Riga Dev Day - Automated Android Continuous IntegrationRiga Dev Day - Automated Android Continuous Integration
Riga Dev Day - Automated Android Continuous Integration
 
Gwt.create
Gwt.createGwt.create
Gwt.create
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 
PhoneGap
PhoneGapPhoneGap
PhoneGap
 
manual
manualmanual
manual
 
manual
manualmanual
manual
 
Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
 
Jetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedJetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO Extended
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Automated User Tests with Apache Flex

  • 1. Automated User Tests with Apache Flex Gert Poppe @gert789
  • 2. About me A Belgian consultant working at Stack & Heap. A passionate RIA developer. A ZEND certified PHP Engineer. A huge fan of the Randori Framework.
  • 3. What are we talking about? Wikipedia says: ... test automation is the use of special software (separate from the software being tested) to control the execution of tests and the comparison of actual outcomes to predicted outcomes. Test automation can automate some repetitive but necessary tasks in a formalized testing process already in place, or add additional testing that would be difficult to perform manually ...
  • 4. Why should you bother? ● Efficiency ● More complete error reports ● Huge time savings ● A more complete code coverage
  • 5. Why did we bother? While taking over an existing project ● Huge and complicated code base ● No existing unit tests ● Complaints by users: ○ a lot of bugs in the GUI ○ a lot of recurrent bugs
  • 6. How did we start?
  • 7. External testing tool Selenium A suite of tools to automate your web browser. External Interface communication between your browser and the Flash Player.
  • 8. ● Java Test ○ Selenium for Java ○ Standalone Selenium server ○ FlexiumLink and FlashSelenium ● Flex Application ○ Flexium https://github.com/StackAndHeap/flexium The Selenium setup
  • 9. DEMO Available on our github https://github.com/StackAndHeap/flexium
  • 10. public Boolean click(String objectId) throws Exception { delay(); if(isReady()) { String result = call("doFlexClick", objectId, ""); return checkResult(result); } return false; } Under the hood - Selenium (1)
  • 11. public Boolean click(String objectId) throws Exception { delay(); if(isReady()) { String result = call("doFlexClick", objectId, ""); return checkResult(result); } return false; } Under the hood - Selenium (1)
  • 12. public Boolean click(String objectId) throws Exception { delay(); if(isReady()) { String result = call("doFlexClick", objectId, ""); return checkResult(result); } return false; } Under the hood - Selenium (1)
  • 13. public Boolean click(String objectId) throws Exception { delay(); if(isReady()) { String result = call("doFlexClick", objectId, ""); return checkResult(result); } return false; } Under the hood - Selenium (1)
  • 14. public Boolean click(String objectId) throws Exception { delay(); if(isReady()) { String result = call("doFlexClick", objectId, ""); return checkResult(result); } return false; } Under the hood - Selenium (1)
  • 15. Under the hood - Selenium (2)
  • 16. Under the hood - Selenium (3)
  • 17. ● Flexium ○ Compiles into your application ○ Parsing of your applications Stage ○ Registers your (custom) commands Under the hood - Apache Flex (1)
  • 18. Compiles into your application ... separate from the software being tested... 1) Use a Mixin ... [Mixin] public class Flexium extends Sprite { ... Under the hood - Apache Flex (2)
  • 19. Compiles into your application ... separate from the software being tested... 2) Include library include-libraries library [...] Under the hood - Apache Flex (2)
  • 20. Parsing of your applications stage Every component that gets added to the stage will be parsed by the AS3-commons Stage Processing Library http://as3commons.org/as3-commons-stageprocessing/index.html Under the hood - Apache Flex (3)
  • 21. Parsing of your applications stage with AS3Commons private var _registry:FlashStageObjectProcessorRegistry; private function initProcessor():void { _registry = new FlashStageObjectProcessorRegistry(); _registry.useStageDestroyers = true; _registry.registerStageObjectProcessor( new EventDispatchingObjectProcessor(this), new EventDispatchingObjectSelector() ); _registry.initialize(); } Under the hood - Apache Flex (4)
  • 22. Parsing of your applications stage with AS3Commons private var _registry:FlashStageObjectProcessorRegistry; private function initProcessor():void { _registry = new FlashStageObjectProcessorRegistry(); _registry.useStageDestroyers = true; _registry.registerStageObjectProcessor( new EventDispatchingObjectProcessor(this), new EventDispatchingObjectSelector() ); _registry.initialize(); } Under the hood - Apache Flex (4)
  • 23. Parsing of your applications stage with AS3Commons private var _registry:FlashStageObjectProcessorRegistry; private function initProcessor():void { _registry = new FlashStageObjectProcessorRegistry(); _registry.useStageDestroyers = true; _registry.registerStageObjectProcessor( new EventDispatchingObjectProcessor(this), new EventDispatchingObjectSelector() ); _registry.initialize(); } Under the hood - Apache Flex (4)
  • 24. Parsing of your applications stage with AS3Commons private var _registry:FlashStageObjectProcessorRegistry; private function initProcessor():void { _registry = new FlashStageObjectProcessorRegistry(); _registry.useStageDestroyers = true; _registry.registerStageObjectProcessor( new EventDispatchingObjectProcessor(this), new EventDispatchingObjectSelector() ); _registry.initialize(); } Under the hood - Apache Flex (4)
  • 25. Parsing of your applications stage with AS3Commons public class EventDispatchingObjectSelector implements IObjectSelector { public function approve(object:Object):Boolean { return object is UIComponent; } } Under the hood - Apache Flex (5)
  • 26. Parsing of your applications stage with AS3Commons public function process(displayObject:DisplayObject):DisplayObject { _stageParser.addElement((displayObject as UIComponent).id, displayObject); return displayObject; } public function destroy(displayObject:DisplayObject):DisplayObject { _stageParser.removeElement((displayObject as UIComponent).id); return displayObject; } Under the hood - Apache Flex (6)
  • 27. Under the hood - Apache Flex (7) Registers your (custom) commands public class MouseAction extends AbstractAction implements IAction { public function MouseAction(parser:StageParser) { super(parser); } public function attachActions():void { attach("click", doFlexClick); } public function doFlexClick(id:String, args:String):String { var child:Object = parser.getElementById(id); if (child == null) { return Errors.OBJECT_NOT_FOUND; } return String(child.dispatchEvent(new MouseEvent(MouseEvent.CLICK))); } }
  • 28. Under the hood - Apache Flex (7) Registers your (custom) commands public class MouseAction extends AbstractAction implements IAction { public function MouseAction(parser:StageParser) { super(parser); } public function attachActions():void { attach("click", doFlexClick); } public function doFlexClick(id:String, args:String):String { var child:Object = parser.getElementById(id); if (child == null) { return Errors.OBJECT_NOT_FOUND; } return String(child.dispatchEvent(new MouseEvent(MouseEvent.CLICK))); } }
  • 29. Under the hood - Apache Flex (7) Registers your (custom) commands public class MouseAction extends AbstractAction implements IAction { public function MouseAction(parser:StageParser) { super(parser); } public function attachActions():void { attach("click", doFlexClick); } public function doFlexClick(id:String, args:String):String { var child:Object = parser.getElementById(id); if (child == null) { return Errors.OBJECT_NOT_FOUND; } return String(child.dispatchEvent(new MouseEvent(MouseEvent.CLICK))); } }
  • 30. Under the hood - Apache Flex (7) Registers your (custom) commands public class MouseAction extends AbstractAction implements IAction { public function MouseAction(parser:StageParser) { super(parser); } public function attachActions():void { attach("click", doFlexClick); } public function doFlexClick(id:String, args:String):String { var child:Object = parser.getElementById(id); if (child == null) { return Errors.OBJECT_NOT_FOUND; } return String(child.dispatchEvent(new MouseEvent(MouseEvent.CLICK))); } }
  • 31. Under the hood - Apache Flex (7) Registers your (custom) commands public class MouseAction extends AbstractAction implements IAction { public function MouseAction(parser:StageParser) { super(parser); } public function attachActions():void { attach("click", doFlexClick); } public function doFlexClick(id:String, args:String):String { var child:Object = parser.getElementById(id); if (child == null) { return Errors.OBJECT_NOT_FOUND; } return String(child.dispatchEvent(new MouseEvent(MouseEvent.CLICK))); } }
  • 32. Under the hood - Apache Flex (7) Registers your (custom) commands public class MouseAction extends AbstractAction implements IAction { public function MouseAction(parser:StageParser) { super(parser); } public function attachActions():void { attach("click", doFlexClick); } public function doFlexClick(id:String, args:String):String { var child:Object = parser.getElementById(id); if (child == null) { return Errors.OBJECT_NOT_FOUND; } return String(child.dispatchEvent(new MouseEvent(MouseEvent.CLICK))); } }
  • 33. FYI ● working with data ○ mock data ■ same result on every test ■ same result on every system
  • 34. What's next? ● My way, not the highway... ● Custom components - custom commands