senchacon 2016: the changing landscape of javascript testing - joel watson and subu baskaran

22
Changing Landscape of JavaScript Testing Joel Watson Subu Baskaran

Upload: sencha

Post on 11-Apr-2017

90 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

Changing Landscape of JavaScript Testing

Joel WatsonSubu Baskaran

Page 2: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

Sencha Test 1.x

2

Developers

• Test Early• Test Driven Development• Code Coverage• Test Individual Components• Deliver Quality Code

Test Engineers

• End-to-End Testing• Single Page Applications• Multiple Browser Execution• Browser Farm Integration• CI\CD

Page 3: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

Why Test?

3

Page 4: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

Shift Testing Left

Page 5: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

Unit Testing Ext JS App

• Models

• Views

• Controllers

• Setup and Teardown

• Test before PR

Page 6: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

Application Testing

Page 7: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

The App

• Black Box

• Multiple browsers

• Regression tests

• Mimic user behavior

• Multiple devices

Page 8: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

Issues Faced

• Locators

• Application instability

• Browser updates

• Continuous integration

Page 9: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

Continuous Integration

• True automation- Let the machine do the heavy lifting

• Run Tests at every stage

• Integrate with build systems

• Run tests on multiple environments- QA

- Staging

- Production

• Leverage browser farms

Page 10: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

Sencha Test 2.0

Page 11: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

Sencha Test 2.0

• Leverage WebDriver to write end-to-end tests for multi-page applications

• Create, debug and execute tests using embedded Selenium server and browser

• Use productivity tools to speed up multiple browser\platform testing

Page 12: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

What’s in EA?

• WebDriver Integration

• Multipage Application Testing

• Event Recorder

• Futures API

• Visual Screen Comparison

Page 13: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

Unit Testing

Page 14: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

Why Unit Testing? The Usual Arguments

• Reduce new bugs (hopefully)

• Defend against regressions

• Make refactoring easier

• Satisfy institutional goals for “code coverage”

Page 15: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

Why Unit Testing? The Better Reasons

• Developing tests demonstrates a level of understanding about the code

• It will give you more confidence in your code, less fear about releases

• Easily automatable!!

• Testing FORCES you to implement better design in your code

• Ultimately, testing = a better you

Page 16: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

Benefits of Unit Testing in Sencha Test

• Easily connect to and write tests for your Ext JS (and non-Ext JS) applications, code packages, and custom extensions

• Ability to test code without launching your Ext JS application

• Built-in code editor allows for easy authoring of tests directly within Sencha Test

Page 17: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

Unit Testing Demo

Page 18: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

Functional Testing

Page 19: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

The Challenges of Functional Testing

• Happy path vs. Reality

• Cross-browser (ahem!) distinctiveness

• Testing full applications is simply hard!- Lots of asynchronicity

- Difficult to mock…have to actually test!

Page 20: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

Taming Functional Testing with Sencha Test

• Leverage WebDriver to facilitate functional testing of single-page AND multi-page applications

• Utilize the Futures API to simplify testing of (often) asynchronous actions in real-world applications

• Execute tests across your desired browsers to ensure that your application is behaving as expected

Page 21: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran

Functional Testing Demo

Page 22: SenchaCon 2016: The Changing Landscape of JavaScript Testing - Joel Watson and Subu Baskaran