FuncUnitCrash Course in JavaScript Functional Testingby Brian MoschelOctober 2010
We’re Gonna Test Srchr
The Testing Landscape*
What the FuncUnit?+++=
Want to Functional Test Your JS App?
…with FuncUnit?
Testing === Pain1. Barriers to Entry2. Completely Foreign APIs3. Debugging Across Platforms4. Low Fidelity Event Simulation5. QA and Developers Can’t Communicate
Getting Started Is Annoyingarr
Download & Start Testingarr
You Know I Don’t Speak Spanish!arr
arrSystemUtil.Run"iexplore","http://www.yahoomail.com"Set g=Browser("name:=Yahoo.*").Page("title:=Yahoo.*")g.WebEdit("name:=login").Set "aaa"g.WebEdit("name:=passwd").SetSecure "bbb"g.WebButton("name:=Sign In").Clickg.Link("name:=Inbox.*","html id:=WelcomeInboxFolderLink").Clickg.Link("name:=Sign Out").Click
But I Do Speak jQueryarr
arrtest("JavaScript results",function(){  S('input').click().type("JavaScript")  // wait until we have some results  S('.autocomplete_item').visible(function(){equals( S('.autocomplete_item').size(), 5, "there are 5 results")})});
Cross Platform Debugging?arr
Firebug, Pleasearr
Your Tests Don’t Do What You Thinkarr
arr$(“input”).bind(“focus”, function(ev){  if ( $(this).val() == "Search API" ) {    $(this).val("").removeClass('notFocused')  }})
Accurate Event Simulation: Trust Your Testsarrsyn.js
QA vs. Developersarr
QA is Your Friendarr
A Tested App in 15 Minutesarr Install Learn the API Write a test Debug tests Run tests Hand off to QAhttp://github.com/jupiterjs/srchr
Want more?arrhttp://funcunit.comhttp://jupiterjs.comhttp://javascriptmvc.combrian.moschel@gmail.com@jupiterjs@brianmoschel@funcunit

FuncUnit

Editor's Notes

  • #2 How many of you write jQuery applications? How many of you test them? How many of you enjoy testing them? You're in the right place.Honestly this project is so far ahead of the competition when it comes to functional testing, if you’re not convinced when I’m done, I’ve done a terrible job.
  • #4 Here is a high level overview of what’s out there right now. A bunch of tools written for server side developers who make web pages. Qunit doesn’t really count because its not functional testing.Logic in web applications are moving more into the rich client. These tools are designed for the time when most logic happened on the server after a click or form submission. FuncUnit is designed for the world of rich client web apps.FuncUnit is to Functional testing what jQuery was to JavaScript development. It provides an approachable way to write maintainable cross browser tests.
  • #5 Funcunit is built on the shoulders of giants. Under the hood, it uses Selenium, Qunit, jQuery, Syn.js (a synthetic event simulation library), env.js, and Rhino.
  • #6 We love Selenium. But it wasn’t built for JS developers or by JS developers.
  • #7 FuncUnit will make testing fun, easy, and approachable. It was built by jQuery developers for jQuery developers, and in that sense is the first functional testing tool of its kind.
  • #8 Everyone simply hates testing. Why is that?
  • #9 Setup, Installation, Cost, Difficult APIsQTP costs 5K per license
  • #10 No setup, open source, free, no installation
  • #11 APIs are another language to learn
  • #12 APIs are another language to learn
  • #13 LeveragesjQuery knowledge
  • #14 LeveragesjQuery knowledge
  • #15 Run tests only one way....scripted via serverDebugging across platforms, languagesNo firebug breakpoints
  • #16 Run tests in browserSet firebug breakpoints
  • #17 brittle/low fidelitydoesn’t corectly simulate browser JS eventsNot designed for crazy JS apps, designed for web apps with HTML and navigation
  • #18 For example: selenium clicks simulate a click event, in browser this actually sends a focus event if you’re clicking an input. If your JS code depends on this focus, it will break. There are a LOT of cases like this. Syn was developed to accurately simulate everything possible
  • #19 syn.js, a library that simulates high fidelity browser eventsGoes to extra trouble to make sure each browser works as intended (recorder app that checks how certain keypresses work)TheSizzle of event simulationPicked up by Mootools testing team also
  • #20 Complex scenario to reproduce the issueCan’t send you a URL to easily repo locally
  • #21 Send a URL to a test caseDevs write and maintain tests!
  • #23 Tag line: Get yelled at less