Quality
                                                                  Best Practices
                                 ...
Xavier Agnetti



               Adobe Consulting


               A Flex geek :
                        leader FlexPMD...
François Le Droff



               Adobe TXI (Technology & eXperience Innovation)
               10 ans               ...
François Le Droff


      blog : http://www.droff.com




                                                               ...
Et vous ?

      Flex ?
               FlexUnit ?
               Fluint ?
               FlexCover ?
               F...
Agenda


       Unit Test Best Practice                                   (Alex   )

       FlexUnit
       FlexUnit De...
UnitTest
                                                                  Best Practices




                            ...
Our Agile Testing Principles.




                                                                      Test Everything –
...
Flex - Testing Concerns Separately

     AccidentWizardView Presentation Graphic Layer
   VehicleDescriptorView       MXML...
Our Agile Testing Principles.




                                                   Test First             Test Last




...
State Verification



                                                                  Exercise




                     ...
FlexUnit




                                                                             ®




Copyright 2008 Adobe Syste...
Flex Frameworks and Tools: UnitTesting


       FlexUnit :                                                http://opensour...
Flex Frameworks and Tools: Unit Testing

       FlexUnit
                         Very similar to JUnit




            ...
Flex Frameworks and Tools: UnitTesting


       FlexUnit Html Reports:




                                              ...
Flex Frameworks and Tools: UnitTesting


       FlexUnit Dashboards:




                                                ...
Flex Unit Next


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


       FlexUnit4 :
        http://opensource.adobe.c...
Demo FlexUnit




                                                                                  ®




Copyright 2008 A...
Testing Events

                             Presentation Graphic Layer
                                   MXML           ...
Demo




                                                                         ®




Copyright 2008 Adobe Systems Incor...
Mock




                                                                         ®




Copyright 2008 Adobe Systems Incor...
Isolating The Object under Test



          Production                                              Depended-on Object


...
Substitution via Dependency Injection (IoC)


         public function PolicyPM( policyValidator : IPolicyValidator )
    ...
Behavior Verification Testing What Objects Do Behind the Scenes




                                             Set expec...
Behavior Verification Testing What Objects Do Behind the Scenes




         var mock : PolicyValidatorMock = new
        ...
Our Agile Testing Principles.




                               State Verification First             Behavior Verificatio...
Making Untestable APIs Testable



    Production Code
    public class LocalConnectionWrapper extends LocalConnection
   ...
Making Untestable APIs Testable



      public interface ISendingLocalConnection extends IEventDispatcher
      {
       ...
Substitution via Overriding




             Object under Test                                    Untestable behaviour



...
Substitution via Overriding


     Production Code

    protected function createReceivingConnection() : IReceivingConnect...
Substitution via Overriding




          var mock : LocalConnectionMock = new LocalConnectionMock();
          mock.mock....
Mock tooling




                                                                                 ®




Copyright 2008 Ado...
Mock Frameworks




                                        mock-as3: http://code.google.com/p/mock-as3
                 ...
Code Coverage




                                                                                  ®




Copyright 2008 A...
Code Coverage Flexcover - Custom Compiler Approach


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




                              ...
Code Coverage Flexcover - Custom Compiler Approach


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




                              ...
Hudson




                                                                  ®




Copyright 2008 Adobe Systems Incorporat...
Sonar




                                                                  ®




Copyright 2008 Adobe Systems Incorporate...
Functional Tests




                                                                                     ®




Copyright ...
Flex Frameworks and Tools: Testing


        Functional Testing
                OS:
                         Selenium f...
Load/Stress/Endurance
                                                                          Tests




                ...
Flex Frameworks and Tools: Testing



       Load and Stress Testing
                JMeter, OpenSTA, Grinder
          ...
Static Code Analysis




                                                                                         ®




Co...
Flex Frameworks and Tools: Building : Quality


       Quality Reports within your build
                AS3NCSS
       ...
Flex PMD




                                                                  ®




Copyright 2008 Adobe Systems Incorpor...
Demo FlexPMD




                                                                                 ®




Copyright 2008 Ado...
Build




                                                                          ®




Copyright 2008 Adobe Systems Inc...
Flex Frameworks and Tools: Building


      Ant :
                FlexAntTasks
               Ant : Antennae

•      Ma...
Managing Dependencies


       Maven (or Ant + Ivy)




                Demo : http://localhost:9999/hudson/job/cairngor...
Managing Dependencies




                                                                  ®




Copyright 2008 Adobe Sys...
Flex Frameworks and Tools: UnitTest within your Build


       FlexUnit within your build




                         M...
       FlexPMD within your build




                         Maven




                                                ...
CI




                                                                       ®




Copyright 2008 Adobe Systems Incorpora...
Flex Frameworks and Tools: Building and CC


       Quality within your build : CC




                Demo : http://loc...
Des questions ?

                                                                                    ®




Copyright 2008 ...
Upcoming SlideShare
Loading in...5
×

Quality Best Practices & Toolkit for Enterprise Flex

3,069

Published on

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

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

No Downloads
Views
Total Views
3,069
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
123
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide

Quality Best Practices & Toolkit for Enterprise Flex

  1. 1. Quality Best Practices & Toolkit for Enterprise Flex ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  2. 2. 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.
  3. 3. 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.
  4. 4. François Le Droff  blog : http://www.droff.com ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  5. 5. Et vous ?  Flex ?  FlexUnit ?  Fluint ?  FlexCover ?  FlexMonkey ?  RiaTest ?  Build and CI ?  Ant ?  Maven ?  Hudson ?  ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  6. 6. 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.
  7. 7. UnitTest Best Practices ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  8. 8. Our Agile Testing Principles. Test Everything – Accept and Minimize Frameworks, Integration Untestable Code etc. Test Concerns Separately Test Many Things At Once ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  9. 9. Flex - Testing Concerns Separately AccidentWizardView Presentation Graphic Layer VehicleDescriptorView MXML UIComponent DisplayObject Presentation Behavior Layer AccidentWizardPM VehicleDescriptorPM Presentation Models Utilities Customer Domain / Application Layer CarCompany Utilities / Domain Models Application Models Factories IncidentDescriptor Persistence Layer SaveReportCommand Commands / Brokers / Translators / IncidentReportTranslator Delegates DataModels Utilities “saveReport” Persistence Definition Layer RemoteObject Network Access File Access LocalConnection ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  10. 10. 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.
  11. 11. State Verification Exercise Assert state Unit test Object under test Assert return ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  12. 12. FlexUnit ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  13. 13. Flex Frameworks and Tools: UnitTesting  FlexUnit : http://opensource.adobe.com/wiki/display/flexunit/FlexUnit ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  14. 14. Flex Frameworks and Tools: Unit Testing  FlexUnit  Very similar to JUnit  Event test enabled ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  15. 15. Flex Frameworks and Tools: UnitTesting  FlexUnit Html Reports: ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  16. 16. Flex Frameworks and Tools: UnitTesting  FlexUnit Dashboards: ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  17. 17. Flex Unit Next  Fluint : http://code.google.com/p/fluint/  FlexUnit4 : http://opensource.adobe.com/wiki/display/flexunit/FlexUnit+4+feature+ov erview ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  18. 18. Demo FlexUnit ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  19. 19. Testing Events Presentation Graphic Layer MXML UIComponent DisplayObject Presentation Behavior Layer Presentation Models Utilities Domain / Application Layer Domain Models Utilities / Application Models Factories Persistence Layer Commands / Brokers / Translators / Delegates DataModels Utilities Persistence Definition Layer Network Access File Access LocalConnection ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  20. 20. Demo ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  21. 21. Mock ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  22. 22. Isolating The Object under Test Production Depended-on Object Object under Test Unit Tests Test Double ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  23. 23. Substitution via Dependency Injection (IoC) public function PolicyPM( policyValidator : IPolicyValidator ) { } model = new PolicyPM( new PolicyValidator() ); model = new PolicyPM( new PolicyValidatorDummy() ); Substitution via Dependency Injection Interface Domain Object under Test Interface Domain Test Double Interface ® 15 Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  24. 24. Behavior Verification Testing What Objects Do Behind the Scenes Set expected PolicyValidatorMock behavior Assert state Exercise PolicyPMTest Exercise PolicyPM ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  25. 25. 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.
  26. 26. Our Agile Testing Principles. State Verification First Behavior Verification Testing Public API Testing Internal Behavior Write Test as Code Write Java/AS Docs Examples ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  27. 27. Making Untestable APIs Testable Production Code public class LocalConnectionWrapper extends LocalConnection implements ILocalConnection { } public interface ILocalConnection extends ISendingLocalConnection, IReceivingLocalConnection { } ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  28. 28. 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.
  29. 29. Substitution via Overriding Object under Test Untestable behaviour Test Subclass Substitution ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  30. 30. Substitution via Overriding Production Code protected function createReceivingConnection() : IReceivingConnection { return new LocalConnectionWrapper(); } Test Subclass override protected function createReceivingConnection() : IReceivingConnection { return new LocalConnectionMock(); } ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  31. 31. 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.
  32. 32. Mock tooling ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  33. 33. 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.
  34. 34. Code Coverage ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  35. 35. Code Coverage Flexcover - Custom Compiler Approach http://code.google.com/p/flexcover ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  36. 36. Code Coverage Flexcover - Custom Compiler Approach http://code.google.com/p/flexcover ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  37. 37. Hudson ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  38. 38. Sonar ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  39. 39. Functional Tests ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  40. 40. 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.
  41. 41. Load/Stress/Endurance Tests ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  42. 42. 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.
  43. 43. Static Code Analysis ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  44. 44. 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.
  45. 45. Flex PMD ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  46. 46. Demo FlexPMD ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  47. 47. Build ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  48. 48. 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.
  49. 49. Managing Dependencies  Maven (or Ant + Ivy)  Demo : http://localhost:9999/hudson/job/cairngormenterprise/site/dependencies.html ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  50. 50. Managing Dependencies ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  51. 51. 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.
  52. 52.  FlexPMD within your build  Maven ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  53. 53. CI ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  54. 54. 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.
  55. 55. Des questions ? ® Copyright 2008 Adobe Systems Incorporated. All rights reserved.
  1. A particular slide catching your eye?

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

×