quality best practices & toolkit for enterprise flex

Post on 12-Sep-2014

5.031 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Quality Best Practices & Toolkit for Enterprise Flex Presentation given at the French Flex User group : "les tontons flexeurs" on the 21st of July 2009 Author : Xavier Agnetti, François Le Droff (and Alex Ulhmann) Copyright: Adobe

TRANSCRIPT

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Quality Best Practices

& Toolkit for

Enterprise Flex

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Xavier Agnetti

Adobe Consulting

A Flex geek :

leader FlexPMD

Contributeur FlexUnit

conférencier à MAX,

Contact:

xagnetti<at>adobe.com

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

François Le Droff

Adobe TXI (Technology & eXperience Innovation)

10 ans (RIA & web 1+n.0)

OSS geek :

membre de

ossgtp, du ParisJUG,

Tontons Flexeurs

contributeur sur qsos, xradar , fna

conférencier à MAX, Solution Linux, Tontons Flexeurs,

BreizhJUG, RiveriaJUG

Contact:

ledroff<at>adobe.com

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

François Le Droff

blog : http://www.droff.com

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Et vous ?

Flex ?

FlexUnit ?

Fluint ?

FlexCover ?

FlexMonkey ?

RiaTest ?

Build and CI ?

Ant ?

Maven ?

Hudson ?

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Agenda

Unit Test Best Practice (Alex )

FlexUnit

FlexUnit Demo

Mock

Code Coverage

Functional Test

Load Test

Static Code Analysis

Build

Continuous Integration

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

UnitTestBest Practices

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Our Agile Testing Principles.

Test Concerns Separately Test Many Things At Once

Test Everything –

Frameworks, Integration

etc.

Accept and Minimize

Untestable Code

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Persistence Layer

Translators /

Utilities

Commands /

Delegates

Presentation Behavior Layer

Flex - Testing Concerns Separately

Persistence Definition Layer

Network Access

Brokers /

DataModels

File Access LocalConnection

Presentation Graphic Layer

MXML UIComponent DisplayObject

Domain / Application Layer

Utilities /

Factories Domain Models

Utilities

Application Models

Presentation Models

VehicleDescriptorView

AccidentWizardView

VehicleDescriptorPM

AccidentWizardPM

CarCompany

Customer

IncidentDescriptor

SaveReportCommand

IncidentReportTranslator

“saveReport”

RemoteObject

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Our Agile Testing Principles.

Test First Test Last

Run Tests Continuously One Test Suite Rules Them

All

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

State Verification

Object under

test

Exercise

Assert return

Assert stateUnit test

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

FlexUnit

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Flex Frameworks and Tools: UnitTesting

FlexUnit : http://opensource.adobe.com/wiki/display/flexunit/FlexUnit

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Flex Frameworks and Tools: Unit Testing

FlexUnit

Very similar to JUnit

Event test enabled

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Flex Frameworks and Tools: UnitTesting

FlexUnit Html Reports:

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Flex Frameworks and Tools: UnitTesting

FlexUnit Dashboards:

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Flex Unit Next

Fluint : http://code.google.com/p/fluint/

FlexUnit4 : http://opensource.adobe.com/wiki/display/flexunit/FlexUnit+4+feature+overview

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Demo FlexUnit

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Persistence Layer

Translators /

Utilities

Commands /

Delegates

Presentation Behavior Layer

Testing Events

Persistence Definition LayerNetwork Access

Brokers /

DataModels

File Access LocalConnection

Presentation Graphic LayerMXML UIComponent DisplayObject

Domain / Application Layer

Domain Models

Utilities

Application ModelsUtilities /

Factories

Presentation Models

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Demo

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Mock

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Isolating The Object under Test

Object under Test

Depended-on Object

Test Double

Production

Unit Tests

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Substitution via Dependency Injection (IoC)

Substitution via Dependency Injection

Object under Test

Domain

Interface

Interface

Domain Test DoubleInterface

public function PolicyPM( policyValidator : IPolicyValidator )

{

}

model = new PolicyPM( new PolicyValidator() );

model = new PolicyPM( new PolicyValidatorDummy() );

15

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Behavior Verification Testing What Objects Do Behind the Scenes

PolicyPMTest

PolicyValidatorMock

PolicyPM

Set expected

behavior

Assert stateExercise

Exercise

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Behavior Verification Testing What Objects Do Behind the Scenes

var mock : PolicyValidatorMock = new

PolicyValidatorMock();

mock.mock.method( “validate” ).withNoArgs.once;

//exercise

var model : PolicyPM = new PolicyPM( mock );

model.next();

mock.mock.verify();

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Our Agile Testing Principles.

Behavior Verification

Testing Internal Behavior

State Verification First

Testing Public API

Write Test as Code

ExamplesWrite Java/AS Docs

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Making Untestable APIs Testable

public class LocalConnectionWrapper extends LocalConnection

implements ILocalConnection

{

}

Production Code

public interface ILocalConnection extends ISendingLocalConnection,

IReceivingLocalConnection

{

}

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Making Untestable APIs Testable

public interface ISendingLocalConnection extends IEventDispatcher

{

function send( connectionName : String, handler : String, ...args ) : void;

}

public interface IReceivingLocalConnection

{

function set client( value : Object ) : void;

function allowDomain( ...domains ) : void;

function connect( connectionName : String) : void;

function close() : void;

}

20

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Substitution via Overriding

Object under Test Untestable behaviour

Test Subclass Substitution

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Substitution via Overriding

protected function createReceivingConnection() : IReceivingConnection

{

return new LocalConnectionWrapper();

}

Production Code

override protected function createReceivingConnection() :

IReceivingConnection

{

return new LocalConnectionMock();

}

Test Subclass

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Substitution via Overriding

var mock : LocalConnectionMock = new LocalConnectionMock();

mock.mock.method( “send” ).withArgs( “connection” ).once;

//exercise

var connector : TestSubclass = new TestSubclass( mock );

connector.go();

mock.mock.verify();

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Mock tooling

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Mock Frameworks

mock-as3: http://code.google.com/p/mock-as3

Used by Adobe Consulting

Mock4AS: http://code.google.com/p/mock4as

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Code Coverage

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Code Coverage Flexcover - Custom Compiler Approach

http://code.google.com/p/flexcover

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Code Coverage Flexcover - Custom Compiler Approach

http://code.google.com/p/flexcover

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Hudson

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Sonar

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Functional Tests

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Flex Frameworks and Tools: Testing

Functional Testing

OS:

Selenium for Flash

FlexMonkey, FunFX

Mercury QTP

IBM Rational Functional Tester

RIATest

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Load/Stress/Endurance Tests

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Flex Frameworks and Tools: Testing

Load and Stress Testing

JMeter, OpenSTA, Grinder

Other commercial (Flex/AMF specific) products :

NeoLoad

WebLoad

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Static Code Analysis

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Flex Frameworks and Tools: Building : Quality

Quality Reports within your build

AS3NCSS

http://localhost:9999/hudson/job/cairngorm/site/javancss.html

FlexPMD

http://localhost:9999/hudson/job/cairngorm/12/pmdResult/

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Flex PMD

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Demo FlexPMD

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Build

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Flex Frameworks and Tools: Building

Ant :

FlexAntTasks

Ant : Antennae

• Maven :

• Flex-mojos• Alternatives :

• ServeBox (Projet Français)

• and Israfil

• Archetypes

FlexMojos V3 est un projet sonatype

Sonatype et Adobe travaillent ensemble pour le support FB dans m2eclipse

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Managing Dependencies

Maven (or Ant + Ivy)

Demo : http://localhost:9999/hudson/job/cairngormenterprise/site/dependencies.html

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Managing Dependencies

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Flex Frameworks and Tools: UnitTest within your Build

FlexUnit within your build

Maven

FlexMojos V3 est un projet sonatype

Sonatype et Adobe travaillent ensemble pour le support FB dans m2eclipse

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

FlexPMD within your build

Maven

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

CI

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Flex Frameworks and Tools: Building and CC

Quality within your build : CC

Demo : http://localhost:9999/hudson/

®

Copyright 2008 Adobe Systems Incorporated. All rights reserved.

Des questions ?

top related