← Back to team overview

launchpad-dev team mailing list archive

Announcement: YUI XHR tests for Javascript integration testing

 

Hello all.

Yesterday I landed code to write and run YUI XHR tests.  This was an effort that began at the Dublin sprint with Francis, Curtis, Deryck, Steve, and myself.  It had been put aside for awhile, and I brought it to completion.

This is intended to be the replacement for our Windmill tests.  It allows you to run YUI tests with the full application server behind you.  

These tests should be used sparingly.  Favor pure JS tests and pure Python server tests.  Save these YUI XHR tests for tightly focused  integration tests assuring that our server and client code agree on the expected contracts.

Here's a high-level feature list.

 - You can easily write fixtures that allow you to use the standard Launchpad object factory to set up.
- A setup fixture can easily communicate back to the Javascript that called it, giving information about what it created, for instance.
 - There's a setup function to easily log your browser in as any person, including a person created by a factory.
 - A single call, usually in your YUI test's teardown, automatically resets the database after each test, as well as running any additional clean-ups you might need, if any.
 - You can run the tests interactively.
 - It's easy to set the tests up to be run automatically.

A database teardown takes about half a second on my machine, for reference.  In my experience so far, this is typically the most expensive aspect of tests, so 12 tests take around six seconds for me.

If you look at standard_yuixhr_test_template.js and standard_yuixhr_test_template.py in the root of the Launchpad tree, you can see a single test with many comments, giving an example of what you can do.

I also intend to work on bug 724609 very soon, converting ye olde http://bazaar.launchpad.net/~launchpad-pqm/launchpad/stable/view/12450/lib/canonical/launchpad/windmill/jstests/launchpad_ajax.js to the new style, which will give a good extended example of how to use this.

I've updated the wiki to point to the two example templates, and to indicate that we no longer use Windmill.  Please help by identifying areas of insufficient documentation, and maybe even by fixing them yourself if you feel comfortable doing so.

The only issue we've encountered so far is that machines (like VMs) with only 1G of RAM may time out during these automated tests.  Upping it to 2G seems to address the issue.  ec2 test and buildbot are both reliably fine with the new tests so far.

This is the bleeding edge; hopefully no one gets cut too badly. :-)  Let me know if you encounter troubles, and I'll try to help out.

Gary

Follow ups