Windmill

Not logged in - Log In / Register

Revision 16 as of 2009-05-07 00:37:50

Clear message

Windmill for JS Integration Tests

For integration testing that covers JS workflows, our tool of choice is Windmill.

Using Windmill to Test Launchpad

Setting up Windmill

Windmill is included in the Launchpad source tree.

Running the Launchpad Windmill test suite

There is a script called lp-windmill.py in the top-level directory. This is a wrapper around the windmill main script which starts a Launchpad server on port 8085 locally with a fresh database (including all of the standard tests sample data).

The windmill process is then fired off with the command line argument.

So if you want to run all the tests you'd typically use:

For interactive test running and development, it's usually more convenient to run the Launchpad server separately:

The Windmill driver script, windmill.py, is located under the utilities/ directory. Using it, you can start an interactive shell to run tests without setting up and tearing down Launchpad repeatedly:

See the help page on the shell environment.

How are the tests organized

Tests written in python are rooted at lib/canonical/launchpad/windmill/tests.

Tests are divided by applications and then subdivided by workflows.

Tests using the JS API are in lib/canonical/launchpad/windmill/jstests.

Test Writing Tips

I'm using the lazr-js slide-in/slide-out effects and I thought that a natural way to assert that a div was hidden or not was to find the element by id, then do an assertProperty() on its class, like so:

    client.asserts.assertProperty(
        id=u'search-results',
        validator='class|lazr-opened')

This does not work though. I'm sure there's a perfectly good reason why, but the bruises on my forehead prevented me from that particular enlightenment. However Edwin provided a clue to a workaround that uses xpath to find the node with the class you're expecting:

    client.asserts.assertNode(
        xpath="//div[@id='search-results' and @class='lazr-opened']")

Using that will save you a world of hurt.

External resources

Troubleshooting


CategoryJavaScript CategoryTesting