Erik's blog

Code, notes, recipes, general musings

Test-driven JavaScript development with YUI

leave a comment »

Notes from “Test Driven Development with YUI Test” presentation given by Nicholas Zakas

  • Flow:
    1. Define requirements
    2. Write tests to verify requirements are met
    3. Write code to test
    4. Run tests
    5. If test succeed, repeat from step 1 until project is finished. If tests fail, repeat from step 3 until tests pass, and then repeat from step 1 until project is finished
  • Motivations:
    • Even small changes can break a complex app.  Use unit tests and suites of tests to ensure app integrity after each change to the code base.
    • Tasks become well-defined using this methodology
    • We are best positioned to perform QA because we know our code best
  • Tips & tricks:
    • Use a test template to speed up the process
    • Use setUp and tearDown functions to prepare and clean environment, respectively, after each test is run
    • Develop the habit of creating files for code and tests for the code in pairs, e.g. code.js & test_code.js
    • In general, each method gets a test and each object gets a test case
    • In your build process, define a “test” state that inserts YUI test code into the app code base
  • References:
Advertisements

Written by Erik

October 14, 2008 at 6:07 am

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: