Strategies for End-to-End Web Apps Testing

Ariya Hidayat
Ariya Hidayatpassionate technologist
Strategies for End-to-End
                            Ariya Hidayat
       Web Apps Testing
Amazon Kindle
Cloud Reader




Financial Times
Edit


       Develop


                 QA
Code Editing
Do not provoke ambiguities

Avoid silly mistakes
                        Learn better code pattern
Write readable code

                  Improve future maintenance
JavaScript Engine Building Blocks


                               Built-in objects,
                               host objects, ...    Runtime




                                 Syntax
                                  Tree
                                                     Virtual
  Source         Parser                             Machine/
                                                   Interpreter
                  Fast and
                conservative
Parsing Stage

                        identifier           number


                var answer = 42;
            keyword            equal sign       semicolon




                      Variable Declaration




                Identifier
                                            Literal Constant
JavaScript Parser (Written in JavaScript)




          Esprima          UglifyJS
                        Narcissus
        ZeParser
                          Traceur
            Es-Lab
Syntax Tree Visualization




  answer = 42
Style Formatter                     https://github.com/fawek/codepainter




                  Sample code




  Source          CodePainter                  Formatted source


                            Indentation
             Infer coding   Quote for string
                styles      literal
                            Whitespace
Code Outline   Eclipse




Functions
  Variables
Application Structure



Ext.define('My.sample.Person', {                Class manifest
    name: 'Mr. Unknown',
    age: 42,
                                        {
      constructor: function(name) {},       className: 'My.sample.Person',
                                            functions: ['walk', 'run'],
      walk: function(steps) {}              properties: ['name', 'age']
      run: function(steps) {}           }

});
Content Assist (aka Intellisense aka Autocomplete)

                                                                                Eclipse




   http://contraptionsforprogramming.blogspot.com/2012/02/better-javascript-content-assist-in.html
Error Tolerant

          Mismatched quote         var msg =
                                   "Hello’;


              Too many dots        person..age = 18;

                                    
        Incomplete, still typing   if (person.



                                    
                                   'use strict';
         Strict mode violation     with (person) {
                                   }
Code Linting



                      var fs = require('fs'),
 Not a strict equal       esprima = require('./esprima'),
                          files = process.argv.splice(2);
                       
                      files.forEach(function (filename) {
if (x == 9) {             var content = fs.readFileSync(filename, 'utf-8'),
  // do Something             syntax = esprima.parse(content, { loc: true });
                       
}                         JSON.stringify(syntax, function (key, value) {
                              if (key === 'test' && value.operator === '==')
                                  console.log('Line', value.loc.start.line);
                              return value;
                          });
                      });
Copy Paste Mistake




 function inside(point, rect) {
     return (point.x >= rect.x1) && (point.y >= rect.y1) &&
            (point.x <= rect.x2) && (point.y <= rect.y1);
 }
                                              Wrong
                                              check
“Boolean Trap” Finder              http://ariya.ofilabs.com/2011/08/hall-of-api-shame-boolean-trap.html




         Obfuscated choice    var volumeSlider = new Slider(false);




           Double-negative    component.setHidden(false);
                              filter.setCaseInsensitive(false);




Can you make up your mind?    treeItem.setState(true, false);




       The more the merrier   event.initKeyEvent("keypress", true, true,
                              null, null, false, false, false, false, 9,
                              0);
Refactoring Helper




 // Add two numbers          // Add two numbers
 function add(firt, two) {   function add(first, two) {
     return firt + two;          return first + two;
 }                           }
Syntax = Message




var Foo = (function () {
   return {                   module Foo {
     bar: function (x, y) {     export function bar (x, y) {
        // do Something           // do something
      }                         }
   };                         }
};



       ES 5.1                           Harmony
        Today                          ES 6/7, Future
Transpilation


                // Object literal property shorthand.
                function Point(x, y) {
    Harmony         return { x, y };
                }




                // Object literal property shorthand.
     ES 5.1     function Point(x, y) {
                    return { x: x, y: y };
                }
Development
Unit Test Framework




http://www.trollquotes.org/image/5-gandalf-troll-quote.jpg
Automatic Reload




     Modified source   Reload content
Remote Interaction
         http://www.sencha.com/blog/remote-javascript-debugging-on-android/




    Weinre, Adobe Shadow, Remote Web Inspector,...
Fast Smoke Test




                  Feedback
                    Cycle
Precommit Check

Typical Scenario
                            This is
                           awesome!




                      un
               t to r
          forge tests
             the




                             Git: precommit hook
    http://ariya.ofilabs.com/2012/03/git-pre-commit-hook-and-smoke-testing.html
Zombie.js



  var Browser = require("zombie");
   
  browser = new Browser();
  browser.visit("http://mobileconference.nl", function () {
      console.log(browser.text("title"));
  });
PhantomJS (Headless WebKit)


                              Paint

 Normal Browser
                     Layout           Display




                              Paint




                                      X
Headless Operation
                     Layout           Display
Screen Capture = Pixel-Perfect Comparison




      phantomjs rasterize.js URL output
CasperJS


 var casper = require('casper').create();

 casper.start('http://www.mobileconference.nl/', function() {
     this.echo('Page title is: ' + this.evaluate(function() {
         return document.title;
     }), 'INFO');
 });

 casper.run();
Postcommit Quality Metrics



                             Quality Factor 1



        Check-in

                              Quality Factor 2
Identifier Length Distribution
                                                    mean of the identifier length is 8.27 characters
                    750



                    500



                    250



                         0
                             0    5 10 15 20 25 30 35 40 45

  prototype-1.7.0.0.js       SCRIPT_ELEMENT_REJECTS_TEXTNODE_APPENDING
  prototype-1.7.0.0.js       MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED
       jquery-1.7.1.js       subtractsBorderForOverflowNotVisible
  jquery.mobile-1.0.js       getClosestElementWithVirtualBinding
  prototype-1.7.0.0.js       HAS_EXTENDED_CREATE_ELEMENT_SYNTAX



                                  http://ariya.ofilabs.com/2012/05/javascript-identifier-length-distribution.html
Statement Distribution

ExpressionStatement                                        6728


     BlockStatement                                      6353


          IfStatement                      3063


    ReturnStatement                       2878
                                                                var fs = require('fs'),
  VariableDeclaration              2116                             esprima = require('esprima'),
 FunctionDeclaration         371                                    files = process.argv.splice(2);
                                                                 
        ForStatement         293
                                                                files.forEach(function (filename) {
      ForInStatement        143
                                                                    var content = fs.readFileSync(filename, 'utf-8'),
      WhileStatement    131                                             syntax = esprima.parse(content);
     BreakStatement     115                                      
                                                                    JSON.stringify(syntax, function (key, value) {
        TryStatement    84
                                                                        if (key === 'type') {
    EmptyStatement      66
                                                                            if (value.match(/Declaration$/) ||
    ThrowStatement      38
                                                                                value.match(/Statement$/)) {
    SwitchStatement     35                                                          console.log(value);
 ContinueStatement      25                                                      }
                                                                        }
  DoWhileStatement      12
                                                                        return value;
   LabeledStatement     6
                                                                    });
                                                                });




                                                  http://ariya.ofilabs.com/2012/04/most-popular-javascript-statements.html
QA
Platform Proliferation
BusterJS




                              Test Suite
           Server Interface




             Test Server
Selenium



                            Firefox
            Opera          WebDriver       Chrome
           WebDriver                      WebDriver




                           WebDriver




                       WebDriver Client
Code Coverage                                 https://github.com/itay/node-cover
                                              https://github.com/coveraje/coveraje
                                              https://github.com/pmlopes/coberturajs


  x = 42;
  if (false)
      x = -1;




                http://ariya.ofilabs.com/2012/03/javascript-code-coverage-and-esprima.html
Instrumentation for Code Coverage

                                            {
                      var a = 5;
    Statement                                   __statement_ZyyqFc(1);
                                                var a = 5;
                                            }


                                            {
                                                __statement_ZyyqFc(2);
                        foo();
    Expression                                  __expression_kC$jur(3), foo();
                                            }




                                            function foo() {
                   function foo() {             __block_n53cJc(1);
     Block             ...                      ...
                   };                       }




             http://itay.github.com/snug_codecoverage_slides/
Performance via Benchmarks.js


       var suite = new Benchmark.Suite;

       suite.add('String#indexOf', function() {
          'Hello World!'.indexOf('o') > -1;
       })
       .on('complete', function() {
          console.log('Fastest is ' +
            this.filter('fastest').pluck('name'));
       })
       .run();




 JSPerf.com
Performance Baseline




                                             Baseline
     Execution time




                      Application revision
Scalability via Run-time Complexity Analysis

       Array.prototype.swap = function (i, j) {
           var k = this[i]; this[i] = this[j]; this[j] = k;
       }




 Array.prototype.swap = function (i, j) {
 Log({ name: 'Array.prototype.swap', lineNumber: 1,
 range: [23, 94] });
     var k = this[i]; this[i] = this[j]; this[j] = k;
 }




  http://ariya.ofilabs.com/2012/01/scalable-web-apps-the-complexity-issue.html
Execution Tracing
                                           4640 function calls



                                              https://gist.github.com/1823129
     jQuery Mobile startup log



        jquery.js   26    jQuery
        jquery.js  103    init                           undefined,   undefined,
 [object Object]
        jquery.js  274    each                           (Function)
        jquery.js  631    each                           [object Object],
 (Function), undefined
        jquery.js  495    isFunction                     [object Object]
        jquery.js  512    type                           [object Object]
 jquery.mobile.js 1857    [Anonymous]
 jquery.mobile.js  642    [Anonymous]
 jquery.mobile.js  624    enableMouseBindings
 jquery.mobile.js  620    disableTouchBindings




http://ariya.ofilabs.com/2012/02/tracking-javascript-execution-during-startup.html
Wrap-up
Coding style/lint, semantic outline, autocomplete,
 Edit     API usage, refactoring, better syntax




          Test framework, remote control, precommit check,
Develop   automatic reload, fast smoke testing, preflight
          metrics




          Comprehensive browser driver, code coverage,
  QA      performance baseline, execution tracking
To boldly analyze what no man has analyzed before...
Thank You



            ariya.hidayat@gmail.com



            ariya.ofilabs.com



            @AriyaHidayat
1 of 47

Recommended

User Testing by Example by
User Testing by ExampleUser Testing by Example
User Testing by ExampleJeremy Horn
995 views25 slides
QA Tester Junior by
QA Tester JuniorQA Tester Junior
QA Tester JuniorShelby Martin
363 views1 slide
Agile testing and_the_banking_domain_2009 by
Agile testing and_the_banking_domain_2009Agile testing and_the_banking_domain_2009
Agile testing and_the_banking_domain_2009Anil Kumar
444 views4 slides
Is an agile SDLC an oxymoron? by
Is an agile SDLC an oxymoron? Is an agile SDLC an oxymoron?
Is an agile SDLC an oxymoron? Dave Sharrock
2.4K views45 slides
Advanced unit testing – real life examples and mistakes by
Advanced unit testing – real life examples and mistakesAdvanced unit testing – real life examples and mistakes
Advanced unit testing – real life examples and mistakesMilan Vukoje
2.4K views29 slides
Browser-level testing by
Browser-level testingBrowser-level testing
Browser-level testingMartin Kleppmann
3.9K views69 slides

More Related Content

Viewers also liked

End-2-End Monitoring – Der Prüfstand jedes SLA´s – in 15 Minuten erklärt! by
End-2-End Monitoring – Der Prüfstand jedes SLA´s – in 15 Minuten erklärt!End-2-End Monitoring – Der Prüfstand jedes SLA´s – in 15 Minuten erklärt!
End-2-End Monitoring – Der Prüfstand jedes SLA´s – in 15 Minuten erklärt!MAXXYS AG
1.4K views17 slides
Unit-testing and E2E testing in JS by
Unit-testing and E2E testing in JSUnit-testing and E2E testing in JS
Unit-testing and E2E testing in JSMichael Haberman
5.8K views46 slides
The Impact of Big Data On Marketing Analytics (UpStream Software) by
The Impact of Big Data On Marketing Analytics (UpStream Software)The Impact of Big Data On Marketing Analytics (UpStream Software)
The Impact of Big Data On Marketing Analytics (UpStream Software)Revolution Analytics
3.1K views16 slides
Complex End-to-End Testing by
Complex End-to-End TestingComplex End-to-End Testing
Complex End-to-End TestingErika Barron
1.6K views9 slides
End 2-end testing of mean applications by
End 2-end testing of mean applicationsEnd 2-end testing of mean applications
End 2-end testing of mean applicationsMihai-Cristian Fratila
423 views41 slides
Implementing Test Automation: What a Manager Should Know by
Implementing Test Automation: What a Manager Should KnowImplementing Test Automation: What a Manager Should Know
Implementing Test Automation: What a Manager Should KnowSoftServe
582 views18 slides

Viewers also liked(15)

End-2-End Monitoring – Der Prüfstand jedes SLA´s – in 15 Minuten erklärt! by MAXXYS AG
End-2-End Monitoring – Der Prüfstand jedes SLA´s – in 15 Minuten erklärt!End-2-End Monitoring – Der Prüfstand jedes SLA´s – in 15 Minuten erklärt!
End-2-End Monitoring – Der Prüfstand jedes SLA´s – in 15 Minuten erklärt!
MAXXYS AG1.4K views
Unit-testing and E2E testing in JS by Michael Haberman
Unit-testing and E2E testing in JSUnit-testing and E2E testing in JS
Unit-testing and E2E testing in JS
Michael Haberman5.8K views
The Impact of Big Data On Marketing Analytics (UpStream Software) by Revolution Analytics
The Impact of Big Data On Marketing Analytics (UpStream Software)The Impact of Big Data On Marketing Analytics (UpStream Software)
The Impact of Big Data On Marketing Analytics (UpStream Software)
Complex End-to-End Testing by Erika Barron
Complex End-to-End TestingComplex End-to-End Testing
Complex End-to-End Testing
Erika Barron1.6K views
Implementing Test Automation: What a Manager Should Know by SoftServe
Implementing Test Automation: What a Manager Should KnowImplementing Test Automation: What a Manager Should Know
Implementing Test Automation: What a Manager Should Know
SoftServe582 views
Session 12 Activités à venir de la CoP PSS : projet Mobilisation 2.0 by COP_HHA
Session 12 Activités à venir de la CoP PSS : projet Mobilisation 2.0Session 12 Activités à venir de la CoP PSS : projet Mobilisation 2.0
Session 12 Activités à venir de la CoP PSS : projet Mobilisation 2.0
COP_HHA368 views
QA Fes 2016. Gerlof Hoekstra. E2E Testing the Ministry Of Justice Biometric I... by QAFest
QA Fes 2016. Gerlof Hoekstra. E2E Testing the Ministry Of Justice Biometric I...QA Fes 2016. Gerlof Hoekstra. E2E Testing the Ministry Of Justice Biometric I...
QA Fes 2016. Gerlof Hoekstra. E2E Testing the Ministry Of Justice Biometric I...
QAFest805 views
E2E-тестирование мобильных приложений by MoscowJS
E2E-тестирование мобильных приложенийE2E-тестирование мобильных приложений
E2E-тестирование мобильных приложений
MoscowJS657 views
test plan by rosh26
test plan test plan
test plan
rosh26533 views
Strategic Testing (CodeMash 2016) by Dmitry Sharkov
Strategic Testing (CodeMash 2016)Strategic Testing (CodeMash 2016)
Strategic Testing (CodeMash 2016)
Dmitry Sharkov361 views
End-to-End Quality Approach: 14 Levels of Testing by Josiah Renaudin
End-to-End Quality Approach: 14 Levels of TestingEnd-to-End Quality Approach: 14 Levels of Testing
End-to-End Quality Approach: 14 Levels of Testing
Josiah Renaudin1.1K views
End to End Test Management Test Strategy Estimation and Metrics Workshop by QAAgility Technologies
End to End Test Management Test Strategy Estimation and Metrics WorkshopEnd to End Test Management Test Strategy Estimation and Metrics Workshop
End to End Test Management Test Strategy Estimation and Metrics Workshop
JavaOne 2011: Migrating Spring Applications to Java EE 6 by Bert Ertman
JavaOne 2011: Migrating Spring Applications to Java EE 6JavaOne 2011: Migrating Spring Applications to Java EE 6
JavaOne 2011: Migrating Spring Applications to Java EE 6
Bert Ertman119.7K views

More from Ariya Hidayat

Understanding Webkit Rendering by
Understanding Webkit RenderingUnderstanding Webkit Rendering
Understanding Webkit RenderingAriya Hidayat
28.8K views82 slides
Understanding Hardware Acceleration on Mobile Browsers by
Understanding Hardware Acceleration on Mobile BrowsersUnderstanding Hardware Acceleration on Mobile Browsers
Understanding Hardware Acceleration on Mobile BrowsersAriya Hidayat
7K views71 slides
Understanding Hardware Acceleration on Mobile Browsers by
Understanding Hardware Acceleration on Mobile BrowsersUnderstanding Hardware Acceleration on Mobile Browsers
Understanding Hardware Acceleration on Mobile BrowsersAriya Hidayat
17.1K views67 slides
JavaScript Parser Infrastructure for Code Quality Analysis by
JavaScript Parser Infrastructure for Code Quality AnalysisJavaScript Parser Infrastructure for Code Quality Analysis
JavaScript Parser Infrastructure for Code Quality AnalysisAriya Hidayat
5.7K views53 slides
Build HTML5 App (Intel Elements 2011) by
Build HTML5 App (Intel Elements 2011)Build HTML5 App (Intel Elements 2011)
Build HTML5 App (Intel Elements 2011)Ariya Hidayat
11.2K views62 slides
Hybrid Apps (Native + Web) via QtWebKit by
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitAriya Hidayat
2.6K views68 slides

More from Ariya Hidayat(12)

Understanding Webkit Rendering by Ariya Hidayat
Understanding Webkit RenderingUnderstanding Webkit Rendering
Understanding Webkit Rendering
Ariya Hidayat28.8K views
Understanding Hardware Acceleration on Mobile Browsers by Ariya Hidayat
Understanding Hardware Acceleration on Mobile BrowsersUnderstanding Hardware Acceleration on Mobile Browsers
Understanding Hardware Acceleration on Mobile Browsers
Ariya Hidayat7K views
Understanding Hardware Acceleration on Mobile Browsers by Ariya Hidayat
Understanding Hardware Acceleration on Mobile BrowsersUnderstanding Hardware Acceleration on Mobile Browsers
Understanding Hardware Acceleration on Mobile Browsers
Ariya Hidayat17.1K views
JavaScript Parser Infrastructure for Code Quality Analysis by Ariya Hidayat
JavaScript Parser Infrastructure for Code Quality AnalysisJavaScript Parser Infrastructure for Code Quality Analysis
JavaScript Parser Infrastructure for Code Quality Analysis
Ariya Hidayat5.7K views
Build HTML5 App (Intel Elements 2011) by Ariya Hidayat
Build HTML5 App (Intel Elements 2011)Build HTML5 App (Intel Elements 2011)
Build HTML5 App (Intel Elements 2011)
Ariya Hidayat11.2K views
Hybrid Apps (Native + Web) via QtWebKit by Ariya Hidayat
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKit
Ariya Hidayat2.6K views
Analyzing the Performance of Mobile Web by Ariya Hidayat
Analyzing the Performance of Mobile WebAnalyzing the Performance of Mobile Web
Analyzing the Performance of Mobile Web
Ariya Hidayat3.5K views
Hybrid Apps (Native + Web) using WebKit by Ariya Hidayat
Hybrid Apps (Native + Web) using WebKitHybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKit
Ariya Hidayat2K views
Hybrid Apps (Native + Web) using WebKit by Ariya Hidayat
Hybrid Apps (Native + Web) using WebKitHybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKit
Ariya Hidayat2.4K views
Efficient Graphics with Qt by Ariya Hidayat
Efficient Graphics with QtEfficient Graphics with Qt
Efficient Graphics with Qt
Ariya Hidayat8.9K views
Introduction to QtWebKit by Ariya Hidayat
Introduction to QtWebKitIntroduction to QtWebKit
Introduction to QtWebKit
Ariya Hidayat2.9K views

Recently uploaded

【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 by
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院IttrainingIttraining
52 views8 slides
Case Study Copenhagen Energy and Business Central.pdf by
Case Study Copenhagen Energy and Business Central.pdfCase Study Copenhagen Energy and Business Central.pdf
Case Study Copenhagen Energy and Business Central.pdfAitana
16 views3 slides
Mini-Track: Challenges to Network Automation Adoption by
Mini-Track: Challenges to Network Automation AdoptionMini-Track: Challenges to Network Automation Adoption
Mini-Track: Challenges to Network Automation AdoptionNetwork Automation Forum
12 views27 slides
The Research Portal of Catalonia: Growing more (information) & more (services) by
The Research Portal of Catalonia: Growing more (information) & more (services)The Research Portal of Catalonia: Growing more (information) & more (services)
The Research Portal of Catalonia: Growing more (information) & more (services)CSUC - Consorci de Serveis Universitaris de Catalunya
80 views25 slides
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...Bernd Ruecker
37 views69 slides

Recently uploaded(20)

【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 by IttrainingIttraining
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
Case Study Copenhagen Energy and Business Central.pdf by Aitana
Case Study Copenhagen Energy and Business Central.pdfCase Study Copenhagen Energy and Business Central.pdf
Case Study Copenhagen Energy and Business Central.pdf
Aitana16 views
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker37 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software263 views
Transcript: The Details of Description Techniques tips and tangents on altern... by BookNet Canada
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...
BookNet Canada136 views
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf by Dr. Jimmy Schwarzkopf
STKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdfSTKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdf
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf
HTTP headers that make your website go faster - devs.gent November 2023 by Thijs Feryn
HTTP headers that make your website go faster - devs.gent November 2023HTTP headers that make your website go faster - devs.gent November 2023
HTTP headers that make your website go faster - devs.gent November 2023
Thijs Feryn22 views
Voice Logger - Telephony Integration Solution at Aegis by Nirmal Sharma
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at Aegis
Nirmal Sharma39 views
The details of description: Techniques, tips, and tangents on alternative tex... by BookNet Canada
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada127 views
Data Integrity for Banking and Financial Services by Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely21 views

Strategies for End-to-End Web Apps Testing

  • 1. Strategies for End-to-End Ariya Hidayat Web Apps Testing
  • 3. Edit Develop QA
  • 5. Do not provoke ambiguities Avoid silly mistakes Learn better code pattern Write readable code Improve future maintenance
  • 6. JavaScript Engine Building Blocks Built-in objects, host objects, ... Runtime Syntax Tree Virtual Source Parser Machine/ Interpreter Fast and conservative
  • 7. Parsing Stage identifier number var answer = 42; keyword equal sign semicolon Variable Declaration Identifier Literal Constant
  • 8. JavaScript Parser (Written in JavaScript) Esprima UglifyJS Narcissus ZeParser Traceur Es-Lab
  • 10. Style Formatter https://github.com/fawek/codepainter Sample code Source CodePainter Formatted source Indentation Infer coding Quote for string styles literal Whitespace
  • 11. Code Outline Eclipse Functions Variables
  • 12. Application Structure Ext.define('My.sample.Person', { Class manifest name: 'Mr. Unknown',   age: 42, { constructor: function(name) {}, className: 'My.sample.Person',   functions: ['walk', 'run'], walk: function(steps) {} properties: ['name', 'age'] run: function(steps) {} } });
  • 13. Content Assist (aka Intellisense aka Autocomplete) Eclipse http://contraptionsforprogramming.blogspot.com/2012/02/better-javascript-content-assist-in.html
  • 14. Error Tolerant Mismatched quote var msg = "Hello’; Too many dots person..age = 18;   Incomplete, still typing if (person.   'use strict'; Strict mode violation with (person) { }
  • 15. Code Linting var fs = require('fs'), Not a strict equal esprima = require('./esprima'), files = process.argv.splice(2);   files.forEach(function (filename) { if (x == 9) { var content = fs.readFileSync(filename, 'utf-8'), // do Something syntax = esprima.parse(content, { loc: true });   } JSON.stringify(syntax, function (key, value) { if (key === 'test' && value.operator === '==') console.log('Line', value.loc.start.line); return value; }); });
  • 16. Copy Paste Mistake function inside(point, rect) { return (point.x >= rect.x1) && (point.y >= rect.y1) && (point.x <= rect.x2) && (point.y <= rect.y1); } Wrong check
  • 17. “Boolean Trap” Finder http://ariya.ofilabs.com/2011/08/hall-of-api-shame-boolean-trap.html Obfuscated choice var volumeSlider = new Slider(false); Double-negative component.setHidden(false); filter.setCaseInsensitive(false); Can you make up your mind? treeItem.setState(true, false); The more the merrier event.initKeyEvent("keypress", true, true, null, null, false, false, false, false, 9, 0);
  • 18. Refactoring Helper // Add two numbers // Add two numbers function add(firt, two) { function add(first, two) { return firt + two; return first + two; } }
  • 19. Syntax = Message var Foo = (function () { return { module Foo { bar: function (x, y) { export function bar (x, y) { // do Something // do something } } }; } }; ES 5.1 Harmony Today ES 6/7, Future
  • 20. Transpilation // Object literal property shorthand. function Point(x, y) { Harmony return { x, y }; } // Object literal property shorthand. ES 5.1 function Point(x, y) { return { x: x, y: y }; }
  • 23. Automatic Reload Modified source Reload content
  • 24. Remote Interaction http://www.sencha.com/blog/remote-javascript-debugging-on-android/ Weinre, Adobe Shadow, Remote Web Inspector,...
  • 25. Fast Smoke Test Feedback Cycle
  • 26. Precommit Check Typical Scenario This is awesome! un t to r forge tests the Git: precommit hook http://ariya.ofilabs.com/2012/03/git-pre-commit-hook-and-smoke-testing.html
  • 27. Zombie.js var Browser = require("zombie");   browser = new Browser(); browser.visit("http://mobileconference.nl", function () { console.log(browser.text("title")); });
  • 28. PhantomJS (Headless WebKit) Paint Normal Browser Layout Display Paint X Headless Operation Layout Display
  • 29. Screen Capture = Pixel-Perfect Comparison phantomjs rasterize.js URL output
  • 30. CasperJS var casper = require('casper').create(); casper.start('http://www.mobileconference.nl/', function() { this.echo('Page title is: ' + this.evaluate(function() { return document.title; }), 'INFO'); }); casper.run();
  • 31. Postcommit Quality Metrics Quality Factor 1 Check-in Quality Factor 2
  • 32. Identifier Length Distribution mean of the identifier length is 8.27 characters 750 500 250 0 0 5 10 15 20 25 30 35 40 45 prototype-1.7.0.0.js SCRIPT_ELEMENT_REJECTS_TEXTNODE_APPENDING prototype-1.7.0.0.js MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED jquery-1.7.1.js subtractsBorderForOverflowNotVisible jquery.mobile-1.0.js getClosestElementWithVirtualBinding prototype-1.7.0.0.js HAS_EXTENDED_CREATE_ELEMENT_SYNTAX http://ariya.ofilabs.com/2012/05/javascript-identifier-length-distribution.html
  • 33. Statement Distribution ExpressionStatement 6728 BlockStatement 6353 IfStatement 3063 ReturnStatement 2878 var fs = require('fs'), VariableDeclaration 2116 esprima = require('esprima'), FunctionDeclaration 371 files = process.argv.splice(2);   ForStatement 293 files.forEach(function (filename) { ForInStatement 143 var content = fs.readFileSync(filename, 'utf-8'), WhileStatement 131 syntax = esprima.parse(content); BreakStatement 115   JSON.stringify(syntax, function (key, value) { TryStatement 84 if (key === 'type') { EmptyStatement 66 if (value.match(/Declaration$/) || ThrowStatement 38 value.match(/Statement$/)) { SwitchStatement 35 console.log(value); ContinueStatement 25 } } DoWhileStatement 12 return value; LabeledStatement 6 }); }); http://ariya.ofilabs.com/2012/04/most-popular-javascript-statements.html
  • 34. QA
  • 36. BusterJS Test Suite Server Interface Test Server
  • 37. Selenium Firefox Opera WebDriver Chrome WebDriver WebDriver WebDriver WebDriver Client
  • 38. Code Coverage https://github.com/itay/node-cover https://github.com/coveraje/coveraje https://github.com/pmlopes/coberturajs x = 42; if (false) x = -1; http://ariya.ofilabs.com/2012/03/javascript-code-coverage-and-esprima.html
  • 39. Instrumentation for Code Coverage { var a = 5; Statement __statement_ZyyqFc(1); var a = 5; } { __statement_ZyyqFc(2); foo(); Expression __expression_kC$jur(3), foo(); } function foo() { function foo() { __block_n53cJc(1); Block ... ... }; } http://itay.github.com/snug_codecoverage_slides/
  • 40. Performance via Benchmarks.js var suite = new Benchmark.Suite; suite.add('String#indexOf', function() { 'Hello World!'.indexOf('o') > -1; }) .on('complete', function() { console.log('Fastest is ' + this.filter('fastest').pluck('name')); }) .run(); JSPerf.com
  • 41. Performance Baseline Baseline Execution time Application revision
  • 42. Scalability via Run-time Complexity Analysis Array.prototype.swap = function (i, j) { var k = this[i]; this[i] = this[j]; this[j] = k; } Array.prototype.swap = function (i, j) { Log({ name: 'Array.prototype.swap', lineNumber: 1, range: [23, 94] }); var k = this[i]; this[i] = this[j]; this[j] = k; } http://ariya.ofilabs.com/2012/01/scalable-web-apps-the-complexity-issue.html
  • 43. Execution Tracing 4640 function calls https://gist.github.com/1823129 jQuery Mobile startup log jquery.js 26 jQuery jquery.js 103 init undefined, undefined, [object Object] jquery.js 274 each (Function) jquery.js 631 each [object Object], (Function), undefined jquery.js 495 isFunction [object Object] jquery.js 512 type [object Object] jquery.mobile.js 1857 [Anonymous] jquery.mobile.js 642 [Anonymous] jquery.mobile.js 624 enableMouseBindings jquery.mobile.js 620 disableTouchBindings http://ariya.ofilabs.com/2012/02/tracking-javascript-execution-during-startup.html
  • 45. Coding style/lint, semantic outline, autocomplete, Edit API usage, refactoring, better syntax Test framework, remote control, precommit check, Develop automatic reload, fast smoke testing, preflight metrics Comprehensive browser driver, code coverage, QA performance baseline, execution tracking
  • 46. To boldly analyze what no man has analyzed before...
  • 47. Thank You ariya.hidayat@gmail.com ariya.ofilabs.com @AriyaHidayat