JavaScript Unit Testing with YUI Test

imagem

Hi,

some posts ago I talked about JavaScript and user interface testing using Selenium. Today, I will present another option to test your JavaScript code.

YUI Test is a testing framework for browser-based JavaScript solutions, providing JavaScript Unit Testing. While not a direct part from any specific xUnit framework, YUI Test does derive some characteristics from nUnit and JUnit.

Here are some of YUI Test features:

  • Rapid creation of test cases through simple syntax.
  • Advanced failure detection for methods that throw errors.
  • Grouping of related test cases using test suites.
  • Asynchronous tests for testing events and Ajax communication.
  • DOM Event simulation in all A-grade browsers.

To start using YUI Test, you must walkthrough some steps:

  1. Include required YUI Test files into your html created file
  2. Write your javascript piece of code
  3. Create a test case
  4. Execute tests

There is straightforward tutorial and a 48 minutes video presented by Yahoo! engineer Nicholas C. Zakas in YUI Blog. It’s a good opportunity to add some TDD to your JavaScript code and improve project quality and maintenance.

See you,


Fernando

Leave a comment