automated user tests with apache flex

Post on 04-Dec-2014

223 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

TRANSCRIPT

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

SeleniumA suite of tools to automate your web browser.

External Interfacecommunication 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

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 AS3Commonsprivate 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 AS3Commonsprivate 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 AS3Commonsprivate 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 AS3Commonsprivate 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 AS3Commonspublic 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 AS3Commonspublic 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) commandspublic 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) commandspublic 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) commandspublic 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) commandspublic 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) commandspublic 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) commandspublic 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

QUESTIONS?

Twitter: @gert789Email: gert.poppe@stackandheap.com

top related