[Windmill-dev] Tests in native JavaScript
Matthew Eernisse
mde at osafoundation.org
Fri Aug 24 16:08:31 PDT 2007
I sat down to write some Windmill tests for recurring items in Cosmo,
and realized that the types of asserts available with the current
JSON/Python tests simply weren't sufficient for the specific stuff I
wanted to test for. I immediately started wanting the ability to write
tests directly in JavaScript.
I wasn't thinking of this in the conext of JSUnit integration -- but
since there's already an established convention with JSUnit, it kind of
makes sense to me that any pure-JS test feature we add would be
compatible with JSUnit tests.
That way people (including us) could reuse their existing tests. And
instead of running these tests against contrived test fixtures set up
with JS in the test environment, they can run these tests against the
data generated by actually maniuplating the UI elements the way a user
would. The tests would also run in the environment our UI code runs in
-- our various supported browsers.
The JS code could be easily pulled down by XHR and eval'd to get it into
the testing environment. So, given that what we have now are JSON and
Python tests, that leaves the question of how to invoke the pure-JS
tests in Windmill, and how to report results.
I'm a Web programmer, so the natural comparison that comes to my mind is
HTML markup and programming code in a Web app. Sometimes it's more
appropriate to embed small scraps of code in your markup, a la
PHP/ERuby/PSP/JSP. Sometimes it's more appropriate to have small bits of
markup in a bunch of code (mod_python Publisher, Java Servlets).
Ideally, I think we'd like to give people a similar choice with the JS
tests in Windmill:
1. Pre-load all the JS tests, and have some syntax to invoke specific
tests from inside JSON/Python tests.
2. Run JS tests, and have some syntax we can use inside them to
manipulate the UI the way the current JSON/Python tests do. (Maybe some
kind of adapter and JS objects in the code that look just like the
currently defined JSON tests?)
Thoughts?
Matthew
More information about the Windmill-dev
mailing list