Slide 1

Slide 1 text

END-TO-END UNIT TESTING FOR WEB DEVELOPERS Arthur Kay Sencha, Inc.

Slide 2

Slide 2 text

Who am I? Arthur Kay Solutions Engineer www.akaWebDesign.com @arthurakay

Slide 3

Slide 3 text

UNIT TESTS ARE HARD Common problems and what to do about them.

Slide 4

Slide 4 text

What do I test? • Structure •  Code itself • Logic •  Assertions • Presentation •  Behavior

Slide 5

Slide 5 text

What tools do I use? • Integration • Automation • Easy to install and maintain!

Slide 6

Slide 6 text

Reporting? • Pre-commit hooks •  Prevent mistakes • Continuous Integration •  Fail builds • (Q/A Process)

Slide 7

Slide 7 text

EXPECTATIONS Defining success.

Slide 8

Slide 8 text

Unit Tests Should… •  Prevent regressions •  Compliment greater testing process •  Imply functionality / intent •  Build confidence Should not… •  Imply no bugs exist •  Replace actual QA testing •  Test things at random •  Attempt 100% coverage

Slide 9

Slide 9 text

TOOLS AND EXAMPLES

Slide 10

Slide 10 text

Remember: •  Automation is required •  Solves a specific problem •  Feedback via reporting •  Not all tools integrate the same way! •  Sometimes you need to hack •  Document everything!

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

Unit Tests: Structure • Stable code across browsers • Maintain best practices • Monitor performance Tools: •  JSLint / JSHint •  LintRoller •  W3C Validator •  YSlow •  CSS Lint Automation: •  Node.js •  PhantomJS •  Ant •  CI servers (Travis)

Slide 13

Slide 13 text

Examples LintRoller YSlow

Slide 14

Slide 14 text

Unit Tests: Logic • Write testable code! • Few (or no) DOM dependencies • Models • Validations • Utilities Tools: •  Jasmine •  Siesta •  100 others Automation: •  Node.js •  PhantomJS •  Testacular •  Ant •  CI servers

Slide 15

Slide 15 text

Example Jasmine Testacular

Slide 16

Slide 16 text

Unit Tests: Presentation • Verify functionality or display • Components vs QA Tools: •  Testacular •  Siesta •  Selenium •  CasperJS Automation: •  CI servers •  PhantomJS •  Selenium RC

Slide 17

Slide 17 text

Examples Testacular Siesta

Slide 18

Slide 18 text

END-TO-END TESTING Doesn’t mean test everything!

Slide 19

Slide 19 text

Advice •  Pick your battles •  Weaknesses •  High-impact •  Some testing is better than no testing •  As long as it’s automated •  Remember the “unit” in “Unit Test” •  Solve specific problems •  Use the right tool •  “Set it and forget it”

Slide 20

Slide 20 text

SAMPLE APP - GITHUB https://github.com/arthurakay/CCC-EndToEndTest

Slide 21

Slide 21 text

Links •  For this presentation: •  https://speakerdeck.com/arthurakay •  http://spkr8.com/s/118941 •  https://github.com/arthurakay/ •  Sencha Webinar on Unit Testing: •  https://vimeo.com/58665998 •  Me: •  http://www.akawebdesign.com •  http://www.twitter.com/arthurakay

Slide 22

Slide 22 text

Review •  Unit Tests: •  Structure •  Logic •  Presentation •  Tests are SPECIFIC •  Tests must be AUTOMATED •  Tests need REPORTING

Slide 23

Slide 23 text

Fin